diff --git a/.travis.yml b/.travis.yml index e9964105e..8d39be503 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,10 @@ cache: apt: true install: - pushd $HOME - - travis_retry wget https://github.com/devkitPro/buildscripts/releases/download/devkitARM_r50/devkitARM_r50-linux.tar.xz + - travis_retry wget https://github.com/devkitPro/buildscripts/releases/download/devkitARM_r52/devkitARM_r52-linux.tar.xz - tar xJf devkitARM*.tar.xz + - travis_retry wget https://github.com/devkitPro/devkitarm-rules/releases/download/v1.0.0/devkitarm-rules-1.0.0.tar.xz + - tar xJf devkitarm-rules-*.tar.xz -C $DEVKITARM - travis_retry git clone https://github.com/pret/agbcc.git - cd agbcc && ./build.sh && ./install.sh $TRAVIS_BUILD_DIR - popd diff --git a/common_syms/pokedex.txt b/common_syms/pokedex.txt index 9aa48a74d..c7a297b2a 100644 --- a/common_syms/pokedex.txt +++ b/common_syms/pokedex.txt @@ -1,2 +1,2 @@ gUnusedPokedexU8 -gUnknown_030060B4 +gPokedexVBlankCB diff --git a/data/maps/AlteringCave/map.json b/data/maps/AlteringCave/map.json index 0c28b77b8..d466df7ca 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 7ebcca911..d52f5f038 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 f6dec3c92..d86867fd7 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/NavelRock_B1F/map.json b/data/maps/NavelRock_B1F/map.json index f2354522f..0629b65ec 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 2d4a89bdb..513b27ba0 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 ef8effb57..8c9072586 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 5b9715dc8..bcc420ad5 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 9d8140955..36e0cce99 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 b3ff4f678..b2a56b1b0 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 d477fcf82..ebe78128f 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 91356a495..5361dd4a3 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 4fc93ba1b..9c8cabe06 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 2572c991a..97bdf8831 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 23d33233c..3b01299f4 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 88d0f679a..b7690246e 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 2de0d5771..ffb1172a2 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 50c075fe9..bf47c8416 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 c65aa2062..43670a24f 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 08404c872..6d2e1ff2d 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 a30f1c386..950a473e5 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 f0e1bb8f8..79bbf50c2 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 2ad457e36..fb3c340f3 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 a3f108da1..c02625a61 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 6f8b62608..8b6cf3a10 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 8d3a5b0d2..045ace694 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/data/scripts/secret_base.inc b/data/scripts/secret_base.inc index cf582bba5..b5c3251b5 100644 --- a/data/scripts/secret_base.inc +++ b/data/scripts/secret_base.inc @@ -301,7 +301,7 @@ SecretBase_EventScript_PutAwayDecoration:: @ 8275D2E end SecretBase_EventScript_PutAwayDecorationLoop:: @ 8275D39 - special sub_8129708 + special PutAwayDecorationIteration compare VAR_RESULT, 1 goto_if_eq SecretBase_EventScript_PutAwayDecorationEnd addvar VAR_0x8004, 1 diff --git a/data/specials.inc b/data/specials.inc index dea813a76..fb2e8fe75 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -31,7 +31,7 @@ gSpecials:: @ 81DBA64 def_special GetObjectEventLocalIdByFlag def_special GetSecretBaseTypeInFrontOfPlayer def_special SetSecretBaseOwnerGfxId - def_special sub_8129708 + def_special PutAwayDecorationIteration def_special EnterNewlyCreatedSecretBase def_special SetBattledOwnerFromResult def_special DoSecretBasePCTurnOffEffect diff --git a/graphics/decorations/unk_85a7308.pal b/graphics/decorations/brendan.pal similarity index 100% rename from graphics/decorations/unk_85a7308.pal rename to graphics/decorations/brendan.pal diff --git a/graphics/decorations/unk_85a7328.pal b/graphics/decorations/may.pal similarity index 100% rename from graphics/decorations/unk_85a7328.pal rename to graphics/decorations/may.pal diff --git a/graphics/link_games/pkmnjump_321start2.png b/graphics/link_games/321start.png similarity index 100% rename from graphics/link_games/pkmnjump_321start2.png rename to graphics/link_games/321start.png diff --git a/graphics/link_games/pkmnjump_321start1.png b/graphics/link_games/321start_2.png similarity index 100% rename from graphics/link_games/pkmnjump_321start1.png rename to graphics/link_games/321start_2.png diff --git a/graphics/misc/decoration_unk_85a7358.png b/graphics/misc/decoration_putting_away_cursor.png similarity index 100% rename from graphics/misc/decoration_unk_85a7358.png rename to graphics/misc/decoration_putting_away_cursor.png diff --git a/graphics/pokedex/text.pal b/graphics/pokedex/bg_hoenn.pal similarity index 100% rename from graphics/pokedex/text.pal rename to graphics/pokedex/bg_hoenn.pal diff --git a/graphics/pokedex/national_bg.pal b/graphics/pokedex/bg_national.pal similarity index 100% rename from graphics/pokedex/national_bg.pal rename to graphics/pokedex/bg_national.pal diff --git a/graphics/pokedex/fade.pal b/graphics/pokedex/caught_screen.pal similarity index 100% rename from graphics/pokedex/fade.pal rename to graphics/pokedex/caught_screen.pal diff --git a/graphics/pokedex/tilemap9.bin b/graphics/pokedex/cry_screen.bin similarity index 100% rename from graphics/pokedex/tilemap9.bin rename to graphics/pokedex/cry_screen.bin diff --git a/graphics/pokedex/cry_screen_bg b/graphics/pokedex/cry_screen_bg new file mode 100644 index 000000000..e786232d9 Binary files /dev/null and b/graphics/pokedex/cry_screen_bg differ diff --git a/graphics/pokedex/85B8C10.png b/graphics/pokedex/cry_screen_bg.png similarity index 100% rename from graphics/pokedex/85B8C10.png rename to graphics/pokedex/cry_screen_bg.png diff --git a/graphics/pokedex/tilemap8.bin b/graphics/pokedex/info_screen.bin similarity index 100% rename from graphics/pokedex/tilemap8.bin rename to graphics/pokedex/info_screen.bin diff --git a/graphics/pokedex/menu2.png b/graphics/pokedex/interface.png similarity index 100% rename from graphics/pokedex/menu2.png rename to graphics/pokedex/interface.png diff --git a/graphics/pokedex/tilemap3.bin b/graphics/pokedex/list.bin similarity index 100% rename from graphics/pokedex/tilemap3.bin rename to graphics/pokedex/list.bin diff --git a/graphics/pokedex/tilemap4.bin b/graphics/pokedex/list_underlay.bin similarity index 100% rename from graphics/pokedex/tilemap4.bin rename to graphics/pokedex/list_underlay.bin diff --git a/graphics/pokedex/tilemap6.bin b/graphics/pokedex/screen_select_bar_main.bin similarity index 100% rename from graphics/pokedex/tilemap6.bin rename to graphics/pokedex/screen_select_bar_main.bin diff --git a/graphics/pokedex/tilemap7.bin b/graphics/pokedex/screen_select_bar_submenu.bin similarity index 100% rename from graphics/pokedex/tilemap7.bin rename to graphics/pokedex/screen_select_bar_submenu.bin diff --git a/graphics/pokedex/search2.bin b/graphics/pokedex/search_menu_hoenn.bin similarity index 100% rename from graphics/pokedex/search2.bin rename to graphics/pokedex/search_menu_hoenn.bin diff --git a/graphics/pokedex/search1.bin b/graphics/pokedex/search_menu_national.bin similarity index 100% rename from graphics/pokedex/search1.bin rename to graphics/pokedex/search_menu_national.bin diff --git a/graphics/pokedex/hoenn_bg.pal b/graphics/pokedex/search_results_bg.pal similarity index 100% rename from graphics/pokedex/hoenn_bg.pal rename to graphics/pokedex/search_results_bg.pal diff --git a/graphics/pokedex/tilemap5.bin b/graphics/pokedex/size_screen.bin similarity index 100% rename from graphics/pokedex/tilemap5.bin rename to graphics/pokedex/size_screen.bin diff --git a/graphics/pokedex/black.pal b/graphics/pokedex/size_silhouette.pal similarity index 100% rename from graphics/pokedex/black.pal rename to graphics/pokedex/size_silhouette.pal diff --git a/graphics/pokedex/tilemap1.bin b/graphics/pokedex/start_menu_main.bin similarity index 100% rename from graphics/pokedex/tilemap1.bin rename to graphics/pokedex/start_menu_main.bin diff --git a/graphics/pokedex/tilemap2.bin b/graphics/pokedex/start_menu_search_results.bin similarity index 100% rename from graphics/pokedex/tilemap2.bin rename to graphics/pokedex/start_menu_search_results.bin 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/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/global.h b/include/constants/global.h index 7c96de511..c7063d71c 100644 --- a/include/constants/global.h +++ b/include/constants/global.h @@ -67,6 +67,7 @@ #define FRONTIER_DOUBLES_PARTY_SIZE 4 #define FRONTIER_MULTI_PARTY_SIZE 2 #define MAX_FRONTIER_PARTY_SIZE FRONTIER_DOUBLES_PARTY_SIZE +#define UNION_ROOM_PARTY_SIZE 2 // string lengths #define ITEM_NAME_LENGTH 14 diff --git a/include/constants/region_map_sections.h b/include/constants/region_map_sections.h index 42f3f8282..5e64048dd 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/species.h b/include/constants/species.h index 02e5ea396..8fa5cf77b 100644 --- a/include/constants/species.h +++ b/include/constants/species.h @@ -449,836 +449,845 @@ // National Dex Index Defines -#define NATIONAL_DEX_NONE 0 -#define NATIONAL_DEX_BULBASAUR 1 -#define NATIONAL_DEX_IVYSAUR 2 -#define NATIONAL_DEX_VENUSAUR 3 -#define NATIONAL_DEX_CHARMANDER 4 -#define NATIONAL_DEX_CHARMELEON 5 -#define NATIONAL_DEX_CHARIZARD 6 -#define NATIONAL_DEX_SQUIRTLE 7 -#define NATIONAL_DEX_WARTORTLE 8 -#define NATIONAL_DEX_BLASTOISE 9 -#define NATIONAL_DEX_CATERPIE 10 -#define NATIONAL_DEX_METAPOD 11 -#define NATIONAL_DEX_BUTTERFREE 12 -#define NATIONAL_DEX_WEEDLE 13 -#define NATIONAL_DEX_KAKUNA 14 -#define NATIONAL_DEX_BEEDRILL 15 -#define NATIONAL_DEX_PIDGEY 16 -#define NATIONAL_DEX_PIDGEOTTO 17 -#define NATIONAL_DEX_PIDGEOT 18 -#define NATIONAL_DEX_RATTATA 19 -#define NATIONAL_DEX_RATICATE 20 -#define NATIONAL_DEX_SPEAROW 21 -#define NATIONAL_DEX_FEAROW 22 -#define NATIONAL_DEX_EKANS 23 -#define NATIONAL_DEX_ARBOK 24 -#define NATIONAL_DEX_PIKACHU 25 -#define NATIONAL_DEX_RAICHU 26 -#define NATIONAL_DEX_SANDSHREW 27 -#define NATIONAL_DEX_SANDSLASH 28 -#define NATIONAL_DEX_NIDORAN_F 29 -#define NATIONAL_DEX_NIDORINA 30 -#define NATIONAL_DEX_NIDOQUEEN 31 -#define NATIONAL_DEX_NIDORAN_M 32 -#define NATIONAL_DEX_NIDORINO 33 -#define NATIONAL_DEX_NIDOKING 34 -#define NATIONAL_DEX_CLEFAIRY 35 -#define NATIONAL_DEX_CLEFABLE 36 -#define NATIONAL_DEX_VULPIX 37 -#define NATIONAL_DEX_NINETALES 38 -#define NATIONAL_DEX_JIGGLYPUFF 39 -#define NATIONAL_DEX_WIGGLYTUFF 40 -#define NATIONAL_DEX_ZUBAT 41 -#define NATIONAL_DEX_GOLBAT 42 -#define NATIONAL_DEX_ODDISH 43 -#define NATIONAL_DEX_GLOOM 44 -#define NATIONAL_DEX_VILEPLUME 45 -#define NATIONAL_DEX_PARAS 46 -#define NATIONAL_DEX_PARASECT 47 -#define NATIONAL_DEX_VENONAT 48 -#define NATIONAL_DEX_VENOMOTH 49 -#define NATIONAL_DEX_DIGLETT 50 -#define NATIONAL_DEX_DUGTRIO 51 -#define NATIONAL_DEX_MEOWTH 52 -#define NATIONAL_DEX_PERSIAN 53 -#define NATIONAL_DEX_PSYDUCK 54 -#define NATIONAL_DEX_GOLDUCK 55 -#define NATIONAL_DEX_MANKEY 56 -#define NATIONAL_DEX_PRIMEAPE 57 -#define NATIONAL_DEX_GROWLITHE 58 -#define NATIONAL_DEX_ARCANINE 59 -#define NATIONAL_DEX_POLIWAG 60 -#define NATIONAL_DEX_POLIWHIRL 61 -#define NATIONAL_DEX_POLIWRATH 62 -#define NATIONAL_DEX_ABRA 63 -#define NATIONAL_DEX_KADABRA 64 -#define NATIONAL_DEX_ALAKAZAM 65 -#define NATIONAL_DEX_MACHOP 66 -#define NATIONAL_DEX_MACHOKE 67 -#define NATIONAL_DEX_MACHAMP 68 -#define NATIONAL_DEX_BELLSPROUT 69 -#define NATIONAL_DEX_WEEPINBELL 70 -#define NATIONAL_DEX_VICTREEBEL 71 -#define NATIONAL_DEX_TENTACOOL 72 -#define NATIONAL_DEX_TENTACRUEL 73 -#define NATIONAL_DEX_GEODUDE 74 -#define NATIONAL_DEX_GRAVELER 75 -#define NATIONAL_DEX_GOLEM 76 -#define NATIONAL_DEX_PONYTA 77 -#define NATIONAL_DEX_RAPIDASH 78 -#define NATIONAL_DEX_SLOWPOKE 79 -#define NATIONAL_DEX_SLOWBRO 80 -#define NATIONAL_DEX_MAGNEMITE 81 -#define NATIONAL_DEX_MAGNETON 82 -#define NATIONAL_DEX_FARFETCHD 83 -#define NATIONAL_DEX_DODUO 84 -#define NATIONAL_DEX_DODRIO 85 -#define NATIONAL_DEX_SEEL 86 -#define NATIONAL_DEX_DEWGONG 87 -#define NATIONAL_DEX_GRIMER 88 -#define NATIONAL_DEX_MUK 89 -#define NATIONAL_DEX_SHELLDER 90 -#define NATIONAL_DEX_CLOYSTER 91 -#define NATIONAL_DEX_GASTLY 92 -#define NATIONAL_DEX_HAUNTER 93 -#define NATIONAL_DEX_GENGAR 94 -#define NATIONAL_DEX_ONIX 95 -#define NATIONAL_DEX_DROWZEE 96 -#define NATIONAL_DEX_HYPNO 97 -#define NATIONAL_DEX_KRABBY 98 -#define NATIONAL_DEX_KINGLER 99 -#define NATIONAL_DEX_VOLTORB 100 -#define NATIONAL_DEX_ELECTRODE 101 -#define NATIONAL_DEX_EXEGGCUTE 102 -#define NATIONAL_DEX_EXEGGUTOR 103 -#define NATIONAL_DEX_CUBONE 104 -#define NATIONAL_DEX_MAROWAK 105 -#define NATIONAL_DEX_HITMONLEE 106 -#define NATIONAL_DEX_HITMONCHAN 107 -#define NATIONAL_DEX_LICKITUNG 108 -#define NATIONAL_DEX_KOFFING 109 -#define NATIONAL_DEX_WEEZING 110 -#define NATIONAL_DEX_RHYHORN 111 -#define NATIONAL_DEX_RHYDON 112 -#define NATIONAL_DEX_CHANSEY 113 -#define NATIONAL_DEX_TANGELA 114 -#define NATIONAL_DEX_KANGASKHAN 115 -#define NATIONAL_DEX_HORSEA 116 -#define NATIONAL_DEX_SEADRA 117 -#define NATIONAL_DEX_GOLDEEN 118 -#define NATIONAL_DEX_SEAKING 119 -#define NATIONAL_DEX_STARYU 120 -#define NATIONAL_DEX_STARMIE 121 -#define NATIONAL_DEX_MR_MIME 122 -#define NATIONAL_DEX_SCYTHER 123 -#define NATIONAL_DEX_JYNX 124 -#define NATIONAL_DEX_ELECTABUZZ 125 -#define NATIONAL_DEX_MAGMAR 126 -#define NATIONAL_DEX_PINSIR 127 -#define NATIONAL_DEX_TAUROS 128 -#define NATIONAL_DEX_MAGIKARP 129 -#define NATIONAL_DEX_GYARADOS 130 -#define NATIONAL_DEX_LAPRAS 131 -#define NATIONAL_DEX_DITTO 132 -#define NATIONAL_DEX_EEVEE 133 -#define NATIONAL_DEX_VAPOREON 134 -#define NATIONAL_DEX_JOLTEON 135 -#define NATIONAL_DEX_FLAREON 136 -#define NATIONAL_DEX_PORYGON 137 -#define NATIONAL_DEX_OMANYTE 138 -#define NATIONAL_DEX_OMASTAR 139 -#define NATIONAL_DEX_KABUTO 140 -#define NATIONAL_DEX_KABUTOPS 141 -#define NATIONAL_DEX_AERODACTYL 142 -#define NATIONAL_DEX_SNORLAX 143 -#define NATIONAL_DEX_ARTICUNO 144 -#define NATIONAL_DEX_ZAPDOS 145 -#define NATIONAL_DEX_MOLTRES 146 -#define NATIONAL_DEX_DRATINI 147 -#define NATIONAL_DEX_DRAGONAIR 148 -#define NATIONAL_DEX_DRAGONITE 149 -#define NATIONAL_DEX_MEWTWO 150 -#define NATIONAL_DEX_MEW 151 -#define NATIONAL_DEX_CHIKORITA 152 -#define NATIONAL_DEX_BAYLEEF 153 -#define NATIONAL_DEX_MEGANIUM 154 -#define NATIONAL_DEX_CYNDAQUIL 155 -#define NATIONAL_DEX_QUILAVA 156 -#define NATIONAL_DEX_TYPHLOSION 157 -#define NATIONAL_DEX_TOTODILE 158 -#define NATIONAL_DEX_CROCONAW 159 -#define NATIONAL_DEX_FERALIGATR 160 -#define NATIONAL_DEX_SENTRET 161 -#define NATIONAL_DEX_FURRET 162 -#define NATIONAL_DEX_HOOTHOOT 163 -#define NATIONAL_DEX_NOCTOWL 164 -#define NATIONAL_DEX_LEDYBA 165 -#define NATIONAL_DEX_LEDIAN 166 -#define NATIONAL_DEX_SPINARAK 167 -#define NATIONAL_DEX_ARIADOS 168 -#define NATIONAL_DEX_CROBAT 169 -#define NATIONAL_DEX_CHINCHOU 170 -#define NATIONAL_DEX_LANTURN 171 -#define NATIONAL_DEX_PICHU 172 -#define NATIONAL_DEX_CLEFFA 173 -#define NATIONAL_DEX_IGGLYBUFF 174 -#define NATIONAL_DEX_TOGEPI 175 -#define NATIONAL_DEX_TOGETIC 176 -#define NATIONAL_DEX_NATU 177 -#define NATIONAL_DEX_XATU 178 -#define NATIONAL_DEX_MAREEP 179 -#define NATIONAL_DEX_FLAAFFY 180 -#define NATIONAL_DEX_AMPHAROS 181 -#define NATIONAL_DEX_BELLOSSOM 182 -#define NATIONAL_DEX_MARILL 183 -#define NATIONAL_DEX_AZUMARILL 184 -#define NATIONAL_DEX_SUDOWOODO 185 -#define NATIONAL_DEX_POLITOED 186 -#define NATIONAL_DEX_HOPPIP 187 -#define NATIONAL_DEX_SKIPLOOM 188 -#define NATIONAL_DEX_JUMPLUFF 189 -#define NATIONAL_DEX_AIPOM 190 -#define NATIONAL_DEX_SUNKERN 191 -#define NATIONAL_DEX_SUNFLORA 192 -#define NATIONAL_DEX_YANMA 193 -#define NATIONAL_DEX_WOOPER 194 -#define NATIONAL_DEX_QUAGSIRE 195 -#define NATIONAL_DEX_ESPEON 196 -#define NATIONAL_DEX_UMBREON 197 -#define NATIONAL_DEX_MURKROW 198 -#define NATIONAL_DEX_SLOWKING 199 -#define NATIONAL_DEX_MISDREAVUS 200 -#define NATIONAL_DEX_UNOWN 201 -#define NATIONAL_DEX_WOBBUFFET 202 -#define NATIONAL_DEX_GIRAFARIG 203 -#define NATIONAL_DEX_PINECO 204 -#define NATIONAL_DEX_FORRETRESS 205 -#define NATIONAL_DEX_DUNSPARCE 206 -#define NATIONAL_DEX_GLIGAR 207 -#define NATIONAL_DEX_STEELIX 208 -#define NATIONAL_DEX_SNUBBULL 209 -#define NATIONAL_DEX_GRANBULL 210 -#define NATIONAL_DEX_QWILFISH 211 -#define NATIONAL_DEX_SCIZOR 212 -#define NATIONAL_DEX_SHUCKLE 213 -#define NATIONAL_DEX_HERACROSS 214 -#define NATIONAL_DEX_SNEASEL 215 -#define NATIONAL_DEX_TEDDIURSA 216 -#define NATIONAL_DEX_URSARING 217 -#define NATIONAL_DEX_SLUGMA 218 -#define NATIONAL_DEX_MAGCARGO 219 -#define NATIONAL_DEX_SWINUB 220 -#define NATIONAL_DEX_PILOSWINE 221 -#define NATIONAL_DEX_CORSOLA 222 -#define NATIONAL_DEX_REMORAID 223 -#define NATIONAL_DEX_OCTILLERY 224 -#define NATIONAL_DEX_DELIBIRD 225 -#define NATIONAL_DEX_MANTINE 226 -#define NATIONAL_DEX_SKARMORY 227 -#define NATIONAL_DEX_HOUNDOUR 228 -#define NATIONAL_DEX_HOUNDOOM 229 -#define NATIONAL_DEX_KINGDRA 230 -#define NATIONAL_DEX_PHANPY 231 -#define NATIONAL_DEX_DONPHAN 232 -#define NATIONAL_DEX_PORYGON2 233 -#define NATIONAL_DEX_STANTLER 234 -#define NATIONAL_DEX_SMEARGLE 235 -#define NATIONAL_DEX_TYROGUE 236 -#define NATIONAL_DEX_HITMONTOP 237 -#define NATIONAL_DEX_SMOOCHUM 238 -#define NATIONAL_DEX_ELEKID 239 -#define NATIONAL_DEX_MAGBY 240 -#define NATIONAL_DEX_MILTANK 241 -#define NATIONAL_DEX_BLISSEY 242 -#define NATIONAL_DEX_RAIKOU 243 -#define NATIONAL_DEX_ENTEI 244 -#define NATIONAL_DEX_SUICUNE 245 -#define NATIONAL_DEX_LARVITAR 246 -#define NATIONAL_DEX_PUPITAR 247 -#define NATIONAL_DEX_TYRANITAR 248 -#define NATIONAL_DEX_LUGIA 249 -#define NATIONAL_DEX_HO_OH 250 -#define NATIONAL_DEX_CELEBI 251 +#define NATIONAL_DEX_NONE 0 +#define NATIONAL_DEX_BULBASAUR 1 +#define NATIONAL_DEX_IVYSAUR 2 +#define NATIONAL_DEX_VENUSAUR 3 +#define NATIONAL_DEX_CHARMANDER 4 +#define NATIONAL_DEX_CHARMELEON 5 +#define NATIONAL_DEX_CHARIZARD 6 +#define NATIONAL_DEX_SQUIRTLE 7 +#define NATIONAL_DEX_WARTORTLE 8 +#define NATIONAL_DEX_BLASTOISE 9 +#define NATIONAL_DEX_CATERPIE 10 +#define NATIONAL_DEX_METAPOD 11 +#define NATIONAL_DEX_BUTTERFREE 12 +#define NATIONAL_DEX_WEEDLE 13 +#define NATIONAL_DEX_KAKUNA 14 +#define NATIONAL_DEX_BEEDRILL 15 +#define NATIONAL_DEX_PIDGEY 16 +#define NATIONAL_DEX_PIDGEOTTO 17 +#define NATIONAL_DEX_PIDGEOT 18 +#define NATIONAL_DEX_RATTATA 19 +#define NATIONAL_DEX_RATICATE 20 +#define NATIONAL_DEX_SPEAROW 21 +#define NATIONAL_DEX_FEAROW 22 +#define NATIONAL_DEX_EKANS 23 +#define NATIONAL_DEX_ARBOK 24 +#define NATIONAL_DEX_PIKACHU 25 +#define NATIONAL_DEX_RAICHU 26 +#define NATIONAL_DEX_SANDSHREW 27 +#define NATIONAL_DEX_SANDSLASH 28 +#define NATIONAL_DEX_NIDORAN_F 29 +#define NATIONAL_DEX_NIDORINA 30 +#define NATIONAL_DEX_NIDOQUEEN 31 +#define NATIONAL_DEX_NIDORAN_M 32 +#define NATIONAL_DEX_NIDORINO 33 +#define NATIONAL_DEX_NIDOKING 34 +#define NATIONAL_DEX_CLEFAIRY 35 +#define NATIONAL_DEX_CLEFABLE 36 +#define NATIONAL_DEX_VULPIX 37 +#define NATIONAL_DEX_NINETALES 38 +#define NATIONAL_DEX_JIGGLYPUFF 39 +#define NATIONAL_DEX_WIGGLYTUFF 40 +#define NATIONAL_DEX_ZUBAT 41 +#define NATIONAL_DEX_GOLBAT 42 +#define NATIONAL_DEX_ODDISH 43 +#define NATIONAL_DEX_GLOOM 44 +#define NATIONAL_DEX_VILEPLUME 45 +#define NATIONAL_DEX_PARAS 46 +#define NATIONAL_DEX_PARASECT 47 +#define NATIONAL_DEX_VENONAT 48 +#define NATIONAL_DEX_VENOMOTH 49 +#define NATIONAL_DEX_DIGLETT 50 +#define NATIONAL_DEX_DUGTRIO 51 +#define NATIONAL_DEX_MEOWTH 52 +#define NATIONAL_DEX_PERSIAN 53 +#define NATIONAL_DEX_PSYDUCK 54 +#define NATIONAL_DEX_GOLDUCK 55 +#define NATIONAL_DEX_MANKEY 56 +#define NATIONAL_DEX_PRIMEAPE 57 +#define NATIONAL_DEX_GROWLITHE 58 +#define NATIONAL_DEX_ARCANINE 59 +#define NATIONAL_DEX_POLIWAG 60 +#define NATIONAL_DEX_POLIWHIRL 61 +#define NATIONAL_DEX_POLIWRATH 62 +#define NATIONAL_DEX_ABRA 63 +#define NATIONAL_DEX_KADABRA 64 +#define NATIONAL_DEX_ALAKAZAM 65 +#define NATIONAL_DEX_MACHOP 66 +#define NATIONAL_DEX_MACHOKE 67 +#define NATIONAL_DEX_MACHAMP 68 +#define NATIONAL_DEX_BELLSPROUT 69 +#define NATIONAL_DEX_WEEPINBELL 70 +#define NATIONAL_DEX_VICTREEBEL 71 +#define NATIONAL_DEX_TENTACOOL 72 +#define NATIONAL_DEX_TENTACRUEL 73 +#define NATIONAL_DEX_GEODUDE 74 +#define NATIONAL_DEX_GRAVELER 75 +#define NATIONAL_DEX_GOLEM 76 +#define NATIONAL_DEX_PONYTA 77 +#define NATIONAL_DEX_RAPIDASH 78 +#define NATIONAL_DEX_SLOWPOKE 79 +#define NATIONAL_DEX_SLOWBRO 80 +#define NATIONAL_DEX_MAGNEMITE 81 +#define NATIONAL_DEX_MAGNETON 82 +#define NATIONAL_DEX_FARFETCHD 83 +#define NATIONAL_DEX_DODUO 84 +#define NATIONAL_DEX_DODRIO 85 +#define NATIONAL_DEX_SEEL 86 +#define NATIONAL_DEX_DEWGONG 87 +#define NATIONAL_DEX_GRIMER 88 +#define NATIONAL_DEX_MUK 89 +#define NATIONAL_DEX_SHELLDER 90 +#define NATIONAL_DEX_CLOYSTER 91 +#define NATIONAL_DEX_GASTLY 92 +#define NATIONAL_DEX_HAUNTER 93 +#define NATIONAL_DEX_GENGAR 94 +#define NATIONAL_DEX_ONIX 95 +#define NATIONAL_DEX_DROWZEE 96 +#define NATIONAL_DEX_HYPNO 97 +#define NATIONAL_DEX_KRABBY 98 +#define NATIONAL_DEX_KINGLER 99 +#define NATIONAL_DEX_VOLTORB 100 +#define NATIONAL_DEX_ELECTRODE 101 +#define NATIONAL_DEX_EXEGGCUTE 102 +#define NATIONAL_DEX_EXEGGUTOR 103 +#define NATIONAL_DEX_CUBONE 104 +#define NATIONAL_DEX_MAROWAK 105 +#define NATIONAL_DEX_HITMONLEE 106 +#define NATIONAL_DEX_HITMONCHAN 107 +#define NATIONAL_DEX_LICKITUNG 108 +#define NATIONAL_DEX_KOFFING 109 +#define NATIONAL_DEX_WEEZING 110 +#define NATIONAL_DEX_RHYHORN 111 +#define NATIONAL_DEX_RHYDON 112 +#define NATIONAL_DEX_CHANSEY 113 +#define NATIONAL_DEX_TANGELA 114 +#define NATIONAL_DEX_KANGASKHAN 115 +#define NATIONAL_DEX_HORSEA 116 +#define NATIONAL_DEX_SEADRA 117 +#define NATIONAL_DEX_GOLDEEN 118 +#define NATIONAL_DEX_SEAKING 119 +#define NATIONAL_DEX_STARYU 120 +#define NATIONAL_DEX_STARMIE 121 +#define NATIONAL_DEX_MR_MIME 122 +#define NATIONAL_DEX_SCYTHER 123 +#define NATIONAL_DEX_JYNX 124 +#define NATIONAL_DEX_ELECTABUZZ 125 +#define NATIONAL_DEX_MAGMAR 126 +#define NATIONAL_DEX_PINSIR 127 +#define NATIONAL_DEX_TAUROS 128 +#define NATIONAL_DEX_MAGIKARP 129 +#define NATIONAL_DEX_GYARADOS 130 +#define NATIONAL_DEX_LAPRAS 131 +#define NATIONAL_DEX_DITTO 132 +#define NATIONAL_DEX_EEVEE 133 +#define NATIONAL_DEX_VAPOREON 134 +#define NATIONAL_DEX_JOLTEON 135 +#define NATIONAL_DEX_FLAREON 136 +#define NATIONAL_DEX_PORYGON 137 +#define NATIONAL_DEX_OMANYTE 138 +#define NATIONAL_DEX_OMASTAR 139 +#define NATIONAL_DEX_KABUTO 140 +#define NATIONAL_DEX_KABUTOPS 141 +#define NATIONAL_DEX_AERODACTYL 142 +#define NATIONAL_DEX_SNORLAX 143 +#define NATIONAL_DEX_ARTICUNO 144 +#define NATIONAL_DEX_ZAPDOS 145 +#define NATIONAL_DEX_MOLTRES 146 +#define NATIONAL_DEX_DRATINI 147 +#define NATIONAL_DEX_DRAGONAIR 148 +#define NATIONAL_DEX_DRAGONITE 149 +#define NATIONAL_DEX_MEWTWO 150 +#define NATIONAL_DEX_MEW 151 -#define NATIONAL_DEX_OLD_UNOWN_B 387 -#define NATIONAL_DEX_OLD_UNOWN_C 388 -#define NATIONAL_DEX_OLD_UNOWN_D 389 -#define NATIONAL_DEX_OLD_UNOWN_E 390 -#define NATIONAL_DEX_OLD_UNOWN_F 391 -#define NATIONAL_DEX_OLD_UNOWN_G 392 -#define NATIONAL_DEX_OLD_UNOWN_H 393 -#define NATIONAL_DEX_OLD_UNOWN_I 394 -#define NATIONAL_DEX_OLD_UNOWN_J 395 -#define NATIONAL_DEX_OLD_UNOWN_K 396 -#define NATIONAL_DEX_OLD_UNOWN_L 397 -#define NATIONAL_DEX_OLD_UNOWN_M 398 -#define NATIONAL_DEX_OLD_UNOWN_N 399 -#define NATIONAL_DEX_OLD_UNOWN_O 400 -#define NATIONAL_DEX_OLD_UNOWN_P 401 -#define NATIONAL_DEX_OLD_UNOWN_Q 402 -#define NATIONAL_DEX_OLD_UNOWN_R 403 -#define NATIONAL_DEX_OLD_UNOWN_S 404 -#define NATIONAL_DEX_OLD_UNOWN_T 405 -#define NATIONAL_DEX_OLD_UNOWN_U 406 -#define NATIONAL_DEX_OLD_UNOWN_V 407 -#define NATIONAL_DEX_OLD_UNOWN_W 408 -#define NATIONAL_DEX_OLD_UNOWN_X 409 -#define NATIONAL_DEX_OLD_UNOWN_Y 410 -#define NATIONAL_DEX_OLD_UNOWN_Z 411 +#define KANTO_DEX_COUNT NATIONAL_DEX_MEW -#define NATIONAL_DEX_TREECKO 252 -#define NATIONAL_DEX_GROVYLE 253 -#define NATIONAL_DEX_SCEPTILE 254 -#define NATIONAL_DEX_TORCHIC 255 -#define NATIONAL_DEX_COMBUSKEN 256 -#define NATIONAL_DEX_BLAZIKEN 257 -#define NATIONAL_DEX_MUDKIP 258 -#define NATIONAL_DEX_MARSHTOMP 259 -#define NATIONAL_DEX_SWAMPERT 260 -#define NATIONAL_DEX_POOCHYENA 261 -#define NATIONAL_DEX_MIGHTYENA 262 -#define NATIONAL_DEX_ZIGZAGOON 263 -#define NATIONAL_DEX_LINOONE 264 -#define NATIONAL_DEX_WURMPLE 265 -#define NATIONAL_DEX_SILCOON 266 -#define NATIONAL_DEX_BEAUTIFLY 267 -#define NATIONAL_DEX_CASCOON 268 -#define NATIONAL_DEX_DUSTOX 269 -#define NATIONAL_DEX_LOTAD 270 -#define NATIONAL_DEX_LOMBRE 271 -#define NATIONAL_DEX_LUDICOLO 272 -#define NATIONAL_DEX_SEEDOT 273 -#define NATIONAL_DEX_NUZLEAF 274 -#define NATIONAL_DEX_SHIFTRY 275 -#define NATIONAL_DEX_NINCADA 290 -#define NATIONAL_DEX_NINJASK 291 -#define NATIONAL_DEX_SHEDINJA 292 -#define NATIONAL_DEX_TAILLOW 276 -#define NATIONAL_DEX_SWELLOW 277 -#define NATIONAL_DEX_SHROOMISH 285 -#define NATIONAL_DEX_BRELOOM 286 -#define NATIONAL_DEX_SPINDA 327 -#define NATIONAL_DEX_WINGULL 278 -#define NATIONAL_DEX_PELIPPER 279 -#define NATIONAL_DEX_SURSKIT 283 -#define NATIONAL_DEX_MASQUERAIN 284 -#define NATIONAL_DEX_WAILMER 320 -#define NATIONAL_DEX_WAILORD 321 -#define NATIONAL_DEX_SKITTY 300 -#define NATIONAL_DEX_DELCATTY 301 -#define NATIONAL_DEX_KECLEON 352 -#define NATIONAL_DEX_BALTOY 343 -#define NATIONAL_DEX_CLAYDOL 344 -#define NATIONAL_DEX_NOSEPASS 299 -#define NATIONAL_DEX_TORKOAL 324 -#define NATIONAL_DEX_SABLEYE 302 -#define NATIONAL_DEX_BARBOACH 339 -#define NATIONAL_DEX_WHISCASH 340 -#define NATIONAL_DEX_LUVDISC 370 -#define NATIONAL_DEX_CORPHISH 341 -#define NATIONAL_DEX_CRAWDAUNT 342 -#define NATIONAL_DEX_FEEBAS 349 -#define NATIONAL_DEX_MILOTIC 350 -#define NATIONAL_DEX_CARVANHA 318 -#define NATIONAL_DEX_SHARPEDO 319 -#define NATIONAL_DEX_TRAPINCH 328 -#define NATIONAL_DEX_VIBRAVA 329 -#define NATIONAL_DEX_FLYGON 330 -#define NATIONAL_DEX_MAKUHITA 296 -#define NATIONAL_DEX_HARIYAMA 297 -#define NATIONAL_DEX_ELECTRIKE 309 -#define NATIONAL_DEX_MANECTRIC 310 -#define NATIONAL_DEX_NUMEL 322 -#define NATIONAL_DEX_CAMERUPT 323 -#define NATIONAL_DEX_SPHEAL 363 -#define NATIONAL_DEX_SEALEO 364 -#define NATIONAL_DEX_WALREIN 365 -#define NATIONAL_DEX_CACNEA 331 -#define NATIONAL_DEX_CACTURNE 332 -#define NATIONAL_DEX_SNORUNT 361 -#define NATIONAL_DEX_GLALIE 362 -#define NATIONAL_DEX_LUNATONE 337 -#define NATIONAL_DEX_SOLROCK 338 -#define NATIONAL_DEX_AZURILL 298 -#define NATIONAL_DEX_SPOINK 325 -#define NATIONAL_DEX_GRUMPIG 326 -#define NATIONAL_DEX_PLUSLE 311 -#define NATIONAL_DEX_MINUN 312 -#define NATIONAL_DEX_MAWILE 303 -#define NATIONAL_DEX_MEDITITE 307 -#define NATIONAL_DEX_MEDICHAM 308 -#define NATIONAL_DEX_SWABLU 333 -#define NATIONAL_DEX_ALTARIA 334 -#define NATIONAL_DEX_WYNAUT 360 -#define NATIONAL_DEX_DUSKULL 355 -#define NATIONAL_DEX_DUSCLOPS 356 -#define NATIONAL_DEX_ROSELIA 315 -#define NATIONAL_DEX_SLAKOTH 287 -#define NATIONAL_DEX_VIGOROTH 288 -#define NATIONAL_DEX_SLAKING 289 -#define NATIONAL_DEX_GULPIN 316 -#define NATIONAL_DEX_SWALOT 317 -#define NATIONAL_DEX_TROPIUS 357 -#define NATIONAL_DEX_WHISMUR 293 -#define NATIONAL_DEX_LOUDRED 294 -#define NATIONAL_DEX_EXPLOUD 295 -#define NATIONAL_DEX_CLAMPERL 366 -#define NATIONAL_DEX_HUNTAIL 367 -#define NATIONAL_DEX_GOREBYSS 368 -#define NATIONAL_DEX_ABSOL 359 -#define NATIONAL_DEX_SHUPPET 353 -#define NATIONAL_DEX_BANETTE 354 -#define NATIONAL_DEX_SEVIPER 336 -#define NATIONAL_DEX_ZANGOOSE 335 -#define NATIONAL_DEX_RELICANTH 369 -#define NATIONAL_DEX_ARON 304 -#define NATIONAL_DEX_LAIRON 305 -#define NATIONAL_DEX_AGGRON 306 -#define NATIONAL_DEX_CASTFORM 351 -#define NATIONAL_DEX_VOLBEAT 313 -#define NATIONAL_DEX_ILLUMISE 314 -#define NATIONAL_DEX_LILEEP 345 -#define NATIONAL_DEX_CRADILY 346 -#define NATIONAL_DEX_ANORITH 347 -#define NATIONAL_DEX_ARMALDO 348 -#define NATIONAL_DEX_RALTS 280 -#define NATIONAL_DEX_KIRLIA 281 -#define NATIONAL_DEX_GARDEVOIR 282 -#define NATIONAL_DEX_BAGON 371 -#define NATIONAL_DEX_SHELGON 372 -#define NATIONAL_DEX_SALAMENCE 373 -#define NATIONAL_DEX_BELDUM 374 -#define NATIONAL_DEX_METANG 375 -#define NATIONAL_DEX_METAGROSS 376 -#define NATIONAL_DEX_REGIROCK 377 -#define NATIONAL_DEX_REGICE 378 -#define NATIONAL_DEX_REGISTEEL 379 -#define NATIONAL_DEX_KYOGRE 382 -#define NATIONAL_DEX_GROUDON 383 -#define NATIONAL_DEX_RAYQUAZA 384 -#define NATIONAL_DEX_LATIAS 380 -#define NATIONAL_DEX_LATIOS 381 -#define NATIONAL_DEX_JIRACHI 385 -#define NATIONAL_DEX_DEOXYS 386 -#define NATIONAL_DEX_CHIMECHO 358 +#define NATIONAL_DEX_CHIKORITA 152 +#define NATIONAL_DEX_BAYLEEF 153 +#define NATIONAL_DEX_MEGANIUM 154 +#define NATIONAL_DEX_CYNDAQUIL 155 +#define NATIONAL_DEX_QUILAVA 156 +#define NATIONAL_DEX_TYPHLOSION 157 +#define NATIONAL_DEX_TOTODILE 158 +#define NATIONAL_DEX_CROCONAW 159 +#define NATIONAL_DEX_FERALIGATR 160 +#define NATIONAL_DEX_SENTRET 161 +#define NATIONAL_DEX_FURRET 162 +#define NATIONAL_DEX_HOOTHOOT 163 +#define NATIONAL_DEX_NOCTOWL 164 +#define NATIONAL_DEX_LEDYBA 165 +#define NATIONAL_DEX_LEDIAN 166 +#define NATIONAL_DEX_SPINARAK 167 +#define NATIONAL_DEX_ARIADOS 168 +#define NATIONAL_DEX_CROBAT 169 +#define NATIONAL_DEX_CHINCHOU 170 +#define NATIONAL_DEX_LANTURN 171 +#define NATIONAL_DEX_PICHU 172 +#define NATIONAL_DEX_CLEFFA 173 +#define NATIONAL_DEX_IGGLYBUFF 174 +#define NATIONAL_DEX_TOGEPI 175 +#define NATIONAL_DEX_TOGETIC 176 +#define NATIONAL_DEX_NATU 177 +#define NATIONAL_DEX_XATU 178 +#define NATIONAL_DEX_MAREEP 179 +#define NATIONAL_DEX_FLAAFFY 180 +#define NATIONAL_DEX_AMPHAROS 181 +#define NATIONAL_DEX_BELLOSSOM 182 +#define NATIONAL_DEX_MARILL 183 +#define NATIONAL_DEX_AZUMARILL 184 +#define NATIONAL_DEX_SUDOWOODO 185 +#define NATIONAL_DEX_POLITOED 186 +#define NATIONAL_DEX_HOPPIP 187 +#define NATIONAL_DEX_SKIPLOOM 188 +#define NATIONAL_DEX_JUMPLUFF 189 +#define NATIONAL_DEX_AIPOM 190 +#define NATIONAL_DEX_SUNKERN 191 +#define NATIONAL_DEX_SUNFLORA 192 +#define NATIONAL_DEX_YANMA 193 +#define NATIONAL_DEX_WOOPER 194 +#define NATIONAL_DEX_QUAGSIRE 195 +#define NATIONAL_DEX_ESPEON 196 +#define NATIONAL_DEX_UMBREON 197 +#define NATIONAL_DEX_MURKROW 198 +#define NATIONAL_DEX_SLOWKING 199 +#define NATIONAL_DEX_MISDREAVUS 200 +#define NATIONAL_DEX_UNOWN 201 +#define NATIONAL_DEX_WOBBUFFET 202 +#define NATIONAL_DEX_GIRAFARIG 203 +#define NATIONAL_DEX_PINECO 204 +#define NATIONAL_DEX_FORRETRESS 205 +#define NATIONAL_DEX_DUNSPARCE 206 +#define NATIONAL_DEX_GLIGAR 207 +#define NATIONAL_DEX_STEELIX 208 +#define NATIONAL_DEX_SNUBBULL 209 +#define NATIONAL_DEX_GRANBULL 210 +#define NATIONAL_DEX_QWILFISH 211 +#define NATIONAL_DEX_SCIZOR 212 +#define NATIONAL_DEX_SHUCKLE 213 +#define NATIONAL_DEX_HERACROSS 214 +#define NATIONAL_DEX_SNEASEL 215 +#define NATIONAL_DEX_TEDDIURSA 216 +#define NATIONAL_DEX_URSARING 217 +#define NATIONAL_DEX_SLUGMA 218 +#define NATIONAL_DEX_MAGCARGO 219 +#define NATIONAL_DEX_SWINUB 220 +#define NATIONAL_DEX_PILOSWINE 221 +#define NATIONAL_DEX_CORSOLA 222 +#define NATIONAL_DEX_REMORAID 223 +#define NATIONAL_DEX_OCTILLERY 224 +#define NATIONAL_DEX_DELIBIRD 225 +#define NATIONAL_DEX_MANTINE 226 +#define NATIONAL_DEX_SKARMORY 227 +#define NATIONAL_DEX_HOUNDOUR 228 +#define NATIONAL_DEX_HOUNDOOM 229 +#define NATIONAL_DEX_KINGDRA 230 +#define NATIONAL_DEX_PHANPY 231 +#define NATIONAL_DEX_DONPHAN 232 +#define NATIONAL_DEX_PORYGON2 233 +#define NATIONAL_DEX_STANTLER 234 +#define NATIONAL_DEX_SMEARGLE 235 +#define NATIONAL_DEX_TYROGUE 236 +#define NATIONAL_DEX_HITMONTOP 237 +#define NATIONAL_DEX_SMOOCHUM 238 +#define NATIONAL_DEX_ELEKID 239 +#define NATIONAL_DEX_MAGBY 240 +#define NATIONAL_DEX_MILTANK 241 +#define NATIONAL_DEX_BLISSEY 242 +#define NATIONAL_DEX_RAIKOU 243 +#define NATIONAL_DEX_ENTEI 244 +#define NATIONAL_DEX_SUICUNE 245 +#define NATIONAL_DEX_LARVITAR 246 +#define NATIONAL_DEX_PUPITAR 247 +#define NATIONAL_DEX_TYRANITAR 248 +#define NATIONAL_DEX_LUGIA 249 +#define NATIONAL_DEX_HO_OH 250 +#define NATIONAL_DEX_CELEBI 251 + +#define JOHTO_DEX_COUNT NATIONAL_DEX_CELEBI + +#define NATIONAL_DEX_TREECKO 252 +#define NATIONAL_DEX_GROVYLE 253 +#define NATIONAL_DEX_SCEPTILE 254 +#define NATIONAL_DEX_TORCHIC 255 +#define NATIONAL_DEX_COMBUSKEN 256 +#define NATIONAL_DEX_BLAZIKEN 257 +#define NATIONAL_DEX_MUDKIP 258 +#define NATIONAL_DEX_MARSHTOMP 259 +#define NATIONAL_DEX_SWAMPERT 260 +#define NATIONAL_DEX_POOCHYENA 261 +#define NATIONAL_DEX_MIGHTYENA 262 +#define NATIONAL_DEX_ZIGZAGOON 263 +#define NATIONAL_DEX_LINOONE 264 +#define NATIONAL_DEX_WURMPLE 265 +#define NATIONAL_DEX_SILCOON 266 +#define NATIONAL_DEX_BEAUTIFLY 267 +#define NATIONAL_DEX_CASCOON 268 +#define NATIONAL_DEX_DUSTOX 269 +#define NATIONAL_DEX_LOTAD 270 +#define NATIONAL_DEX_LOMBRE 271 +#define NATIONAL_DEX_LUDICOLO 272 +#define NATIONAL_DEX_SEEDOT 273 +#define NATIONAL_DEX_NUZLEAF 274 +#define NATIONAL_DEX_SHIFTRY 275 +#define NATIONAL_DEX_TAILLOW 276 +#define NATIONAL_DEX_SWELLOW 277 +#define NATIONAL_DEX_WINGULL 278 +#define NATIONAL_DEX_PELIPPER 279 +#define NATIONAL_DEX_RALTS 280 +#define NATIONAL_DEX_KIRLIA 281 +#define NATIONAL_DEX_GARDEVOIR 282 +#define NATIONAL_DEX_SURSKIT 283 +#define NATIONAL_DEX_MASQUERAIN 284 +#define NATIONAL_DEX_SHROOMISH 285 +#define NATIONAL_DEX_BRELOOM 286 +#define NATIONAL_DEX_SLAKOTH 287 +#define NATIONAL_DEX_VIGOROTH 288 +#define NATIONAL_DEX_SLAKING 289 +#define NATIONAL_DEX_NINCADA 290 +#define NATIONAL_DEX_NINJASK 291 +#define NATIONAL_DEX_SHEDINJA 292 +#define NATIONAL_DEX_WHISMUR 293 +#define NATIONAL_DEX_LOUDRED 294 +#define NATIONAL_DEX_EXPLOUD 295 +#define NATIONAL_DEX_MAKUHITA 296 +#define NATIONAL_DEX_HARIYAMA 297 +#define NATIONAL_DEX_AZURILL 298 +#define NATIONAL_DEX_NOSEPASS 299 +#define NATIONAL_DEX_SKITTY 300 +#define NATIONAL_DEX_DELCATTY 301 +#define NATIONAL_DEX_SABLEYE 302 +#define NATIONAL_DEX_MAWILE 303 +#define NATIONAL_DEX_ARON 304 +#define NATIONAL_DEX_LAIRON 305 +#define NATIONAL_DEX_AGGRON 306 +#define NATIONAL_DEX_MEDITITE 307 +#define NATIONAL_DEX_MEDICHAM 308 +#define NATIONAL_DEX_ELECTRIKE 309 +#define NATIONAL_DEX_MANECTRIC 310 +#define NATIONAL_DEX_PLUSLE 311 +#define NATIONAL_DEX_MINUN 312 +#define NATIONAL_DEX_VOLBEAT 313 +#define NATIONAL_DEX_ILLUMISE 314 +#define NATIONAL_DEX_ROSELIA 315 +#define NATIONAL_DEX_GULPIN 316 +#define NATIONAL_DEX_SWALOT 317 +#define NATIONAL_DEX_CARVANHA 318 +#define NATIONAL_DEX_SHARPEDO 319 +#define NATIONAL_DEX_WAILMER 320 +#define NATIONAL_DEX_WAILORD 321 +#define NATIONAL_DEX_NUMEL 322 +#define NATIONAL_DEX_CAMERUPT 323 +#define NATIONAL_DEX_TORKOAL 324 +#define NATIONAL_DEX_SPOINK 325 +#define NATIONAL_DEX_GRUMPIG 326 +#define NATIONAL_DEX_SPINDA 327 +#define NATIONAL_DEX_TRAPINCH 328 +#define NATIONAL_DEX_VIBRAVA 329 +#define NATIONAL_DEX_FLYGON 330 +#define NATIONAL_DEX_CACNEA 331 +#define NATIONAL_DEX_CACTURNE 332 +#define NATIONAL_DEX_SWABLU 333 +#define NATIONAL_DEX_ALTARIA 334 +#define NATIONAL_DEX_ZANGOOSE 335 +#define NATIONAL_DEX_SEVIPER 336 +#define NATIONAL_DEX_LUNATONE 337 +#define NATIONAL_DEX_SOLROCK 338 +#define NATIONAL_DEX_BARBOACH 339 +#define NATIONAL_DEX_WHISCASH 340 +#define NATIONAL_DEX_CORPHISH 341 +#define NATIONAL_DEX_CRAWDAUNT 342 +#define NATIONAL_DEX_BALTOY 343 +#define NATIONAL_DEX_CLAYDOL 344 +#define NATIONAL_DEX_LILEEP 345 +#define NATIONAL_DEX_CRADILY 346 +#define NATIONAL_DEX_ANORITH 347 +#define NATIONAL_DEX_ARMALDO 348 +#define NATIONAL_DEX_FEEBAS 349 +#define NATIONAL_DEX_MILOTIC 350 +#define NATIONAL_DEX_CASTFORM 351 +#define NATIONAL_DEX_KECLEON 352 +#define NATIONAL_DEX_SHUPPET 353 +#define NATIONAL_DEX_BANETTE 354 +#define NATIONAL_DEX_DUSKULL 355 +#define NATIONAL_DEX_DUSCLOPS 356 +#define NATIONAL_DEX_TROPIUS 357 +#define NATIONAL_DEX_CHIMECHO 358 +#define NATIONAL_DEX_ABSOL 359 +#define NATIONAL_DEX_WYNAUT 360 +#define NATIONAL_DEX_SNORUNT 361 +#define NATIONAL_DEX_GLALIE 362 +#define NATIONAL_DEX_SPHEAL 363 +#define NATIONAL_DEX_SEALEO 364 +#define NATIONAL_DEX_WALREIN 365 +#define NATIONAL_DEX_CLAMPERL 366 +#define NATIONAL_DEX_HUNTAIL 367 +#define NATIONAL_DEX_GOREBYSS 368 +#define NATIONAL_DEX_RELICANTH 369 +#define NATIONAL_DEX_LUVDISC 370 +#define NATIONAL_DEX_BAGON 371 +#define NATIONAL_DEX_SHELGON 372 +#define NATIONAL_DEX_SALAMENCE 373 +#define NATIONAL_DEX_BELDUM 374 +#define NATIONAL_DEX_METANG 375 +#define NATIONAL_DEX_METAGROSS 376 +#define NATIONAL_DEX_REGIROCK 377 +#define NATIONAL_DEX_REGICE 378 +#define NATIONAL_DEX_REGISTEEL 379 +#define NATIONAL_DEX_LATIAS 380 +#define NATIONAL_DEX_LATIOS 381 +#define NATIONAL_DEX_KYOGRE 382 +#define NATIONAL_DEX_GROUDON 383 +#define NATIONAL_DEX_RAYQUAZA 384 +#define NATIONAL_DEX_JIRACHI 385 +#define NATIONAL_DEX_DEOXYS 386 + +#define NATIONAL_DEX_COUNT NATIONAL_DEX_DEOXYS + +#define NATIONAL_DEX_OLD_UNOWN_B 387 +#define NATIONAL_DEX_OLD_UNOWN_C 388 +#define NATIONAL_DEX_OLD_UNOWN_D 389 +#define NATIONAL_DEX_OLD_UNOWN_E 390 +#define NATIONAL_DEX_OLD_UNOWN_F 391 +#define NATIONAL_DEX_OLD_UNOWN_G 392 +#define NATIONAL_DEX_OLD_UNOWN_H 393 +#define NATIONAL_DEX_OLD_UNOWN_I 394 +#define NATIONAL_DEX_OLD_UNOWN_J 395 +#define NATIONAL_DEX_OLD_UNOWN_K 396 +#define NATIONAL_DEX_OLD_UNOWN_L 397 +#define NATIONAL_DEX_OLD_UNOWN_M 398 +#define NATIONAL_DEX_OLD_UNOWN_N 399 +#define NATIONAL_DEX_OLD_UNOWN_O 400 +#define NATIONAL_DEX_OLD_UNOWN_P 401 +#define NATIONAL_DEX_OLD_UNOWN_Q 402 +#define NATIONAL_DEX_OLD_UNOWN_R 403 +#define NATIONAL_DEX_OLD_UNOWN_S 404 +#define NATIONAL_DEX_OLD_UNOWN_T 405 +#define NATIONAL_DEX_OLD_UNOWN_U 406 +#define NATIONAL_DEX_OLD_UNOWN_V 407 +#define NATIONAL_DEX_OLD_UNOWN_W 408 +#define NATIONAL_DEX_OLD_UNOWN_X 409 +#define NATIONAL_DEX_OLD_UNOWN_Y 410 +#define NATIONAL_DEX_OLD_UNOWN_Z 411 // Hoenn Dex Index Defines -#define HOENN_DEX_NONE 0 -#define HOENN_DEX_BULBASAUR 203 -#define HOENN_DEX_IVYSAUR 204 -#define HOENN_DEX_VENUSAUR 205 -#define HOENN_DEX_CHARMANDER 206 -#define HOENN_DEX_CHARMELEON 207 -#define HOENN_DEX_CHARIZARD 208 -#define HOENN_DEX_SQUIRTLE 209 -#define HOENN_DEX_WARTORTLE 210 -#define HOENN_DEX_BLASTOISE 211 -#define HOENN_DEX_CATERPIE 212 -#define HOENN_DEX_METAPOD 213 -#define HOENN_DEX_BUTTERFREE 214 -#define HOENN_DEX_WEEDLE 215 -#define HOENN_DEX_KAKUNA 216 -#define HOENN_DEX_BEEDRILL 217 -#define HOENN_DEX_PIDGEY 218 -#define HOENN_DEX_PIDGEOTTO 219 -#define HOENN_DEX_PIDGEOT 220 -#define HOENN_DEX_RATTATA 221 -#define HOENN_DEX_RATICATE 222 -#define HOENN_DEX_SPEAROW 223 -#define HOENN_DEX_FEAROW 224 -#define HOENN_DEX_EKANS 225 -#define HOENN_DEX_ARBOK 226 -#define HOENN_DEX_PIKACHU 156 -#define HOENN_DEX_RAICHU 157 -#define HOENN_DEX_SANDSHREW 112 -#define HOENN_DEX_SANDSLASH 113 -#define HOENN_DEX_NIDORAN_F 227 -#define HOENN_DEX_NIDORINA 228 -#define HOENN_DEX_NIDOQUEEN 229 -#define HOENN_DEX_NIDORAN_M 230 -#define HOENN_DEX_NIDORINO 231 -#define HOENN_DEX_NIDOKING 232 -#define HOENN_DEX_CLEFAIRY 233 -#define HOENN_DEX_CLEFABLE 234 -#define HOENN_DEX_VULPIX 153 -#define HOENN_DEX_NINETALES 154 -#define HOENN_DEX_JIGGLYPUFF 138 -#define HOENN_DEX_WIGGLYTUFF 139 -#define HOENN_DEX_ZUBAT 63 -#define HOENN_DEX_GOLBAT 64 -#define HOENN_DEX_ODDISH 88 -#define HOENN_DEX_GLOOM 89 -#define HOENN_DEX_VILEPLUME 90 -#define HOENN_DEX_PARAS 235 -#define HOENN_DEX_PARASECT 236 -#define HOENN_DEX_VENONAT 237 -#define HOENN_DEX_VENOMOTH 238 -#define HOENN_DEX_DIGLETT 239 -#define HOENN_DEX_DUGTRIO 240 -#define HOENN_DEX_MEOWTH 241 -#define HOENN_DEX_PERSIAN 242 -#define HOENN_DEX_PSYDUCK 158 -#define HOENN_DEX_GOLDUCK 159 -#define HOENN_DEX_MANKEY 243 -#define HOENN_DEX_PRIMEAPE 244 -#define HOENN_DEX_GROWLITHE 245 -#define HOENN_DEX_ARCANINE 246 -#define HOENN_DEX_POLIWAG 247 -#define HOENN_DEX_POLIWHIRL 248 -#define HOENN_DEX_POLIWRATH 249 -#define HOENN_DEX_ABRA 39 -#define HOENN_DEX_KADABRA 40 -#define HOENN_DEX_ALAKAZAM 41 -#define HOENN_DEX_MACHOP 73 -#define HOENN_DEX_MACHOKE 74 -#define HOENN_DEX_MACHAMP 75 -#define HOENN_DEX_BELLSPROUT 250 -#define HOENN_DEX_WEEPINBELL 251 -#define HOENN_DEX_VICTREEBEL 252 -#define HOENN_DEX_TENTACOOL 66 -#define HOENN_DEX_TENTACRUEL 67 -#define HOENN_DEX_GEODUDE 57 -#define HOENN_DEX_GRAVELER 58 -#define HOENN_DEX_GOLEM 59 -#define HOENN_DEX_PONYTA 253 -#define HOENN_DEX_RAPIDASH 254 -#define HOENN_DEX_SLOWPOKE 255 -#define HOENN_DEX_SLOWBRO 256 -#define HOENN_DEX_MAGNEMITE 82 -#define HOENN_DEX_MAGNETON 83 -#define HOENN_DEX_FARFETCHD 257 -#define HOENN_DEX_DODUO 92 -#define HOENN_DEX_DODRIO 93 -#define HOENN_DEX_SEEL 258 -#define HOENN_DEX_DEWGONG 259 -#define HOENN_DEX_GRIMER 106 -#define HOENN_DEX_MUK 107 -#define HOENN_DEX_SHELLDER 260 -#define HOENN_DEX_CLOYSTER 261 -#define HOENN_DEX_GASTLY 262 -#define HOENN_DEX_HAUNTER 263 -#define HOENN_DEX_GENGAR 264 -#define HOENN_DEX_ONIX 265 -#define HOENN_DEX_DROWZEE 266 -#define HOENN_DEX_HYPNO 267 -#define HOENN_DEX_KRABBY 268 -#define HOENN_DEX_KINGLER 269 -#define HOENN_DEX_VOLTORB 84 -#define HOENN_DEX_ELECTRODE 85 -#define HOENN_DEX_EXEGGCUTE 270 -#define HOENN_DEX_EXEGGUTOR 271 -#define HOENN_DEX_CUBONE 272 -#define HOENN_DEX_MAROWAK 273 -#define HOENN_DEX_HITMONLEE 274 -#define HOENN_DEX_HITMONCHAN 275 -#define HOENN_DEX_LICKITUNG 276 -#define HOENN_DEX_KOFFING 108 -#define HOENN_DEX_WEEZING 109 -#define HOENN_DEX_RHYHORN 169 -#define HOENN_DEX_RHYDON 170 -#define HOENN_DEX_CHANSEY 277 -#define HOENN_DEX_TANGELA 278 -#define HOENN_DEX_KANGASKHAN 279 -#define HOENN_DEX_HORSEA 184 -#define HOENN_DEX_SEADRA 185 -#define HOENN_DEX_GOLDEEN 50 -#define HOENN_DEX_SEAKING 51 -#define HOENN_DEX_STARYU 143 -#define HOENN_DEX_STARMIE 144 -#define HOENN_DEX_MR_MIME 280 -#define HOENN_DEX_SCYTHER 281 -#define HOENN_DEX_JYNX 282 -#define HOENN_DEX_ELECTABUZZ 283 -#define HOENN_DEX_MAGMAR 284 -#define HOENN_DEX_PINSIR 167 -#define HOENN_DEX_TAUROS 285 -#define HOENN_DEX_MAGIKARP 52 -#define HOENN_DEX_GYARADOS 53 -#define HOENN_DEX_LAPRAS 286 -#define HOENN_DEX_DITTO 287 -#define HOENN_DEX_EEVEE 288 -#define HOENN_DEX_VAPOREON 289 -#define HOENN_DEX_JOLTEON 290 -#define HOENN_DEX_FLAREON 291 -#define HOENN_DEX_PORYGON 292 -#define HOENN_DEX_OMANYTE 293 -#define HOENN_DEX_OMASTAR 294 -#define HOENN_DEX_KABUTO 295 -#define HOENN_DEX_KABUTOPS 296 -#define HOENN_DEX_AERODACTYL 297 -#define HOENN_DEX_SNORLAX 298 -#define HOENN_DEX_ARTICUNO 299 -#define HOENN_DEX_ZAPDOS 300 -#define HOENN_DEX_MOLTRES 301 -#define HOENN_DEX_DRATINI 302 -#define HOENN_DEX_DRAGONAIR 303 -#define HOENN_DEX_DRAGONITE 304 -#define HOENN_DEX_MEWTWO 305 -#define HOENN_DEX_MEW 306 -#define HOENN_DEX_CHIKORITA 307 -#define HOENN_DEX_BAYLEEF 308 -#define HOENN_DEX_MEGANIUM 309 -#define HOENN_DEX_CYNDAQUIL 310 -#define HOENN_DEX_QUILAVA 311 -#define HOENN_DEX_TYPHLOSION 312 -#define HOENN_DEX_TOTODILE 313 -#define HOENN_DEX_CROCONAW 314 -#define HOENN_DEX_FERALIGATR 315 -#define HOENN_DEX_SENTRET 316 -#define HOENN_DEX_FURRET 317 -#define HOENN_DEX_HOOTHOOT 318 -#define HOENN_DEX_NOCTOWL 319 -#define HOENN_DEX_LEDYBA 320 -#define HOENN_DEX_LEDIAN 321 -#define HOENN_DEX_SPINARAK 322 -#define HOENN_DEX_ARIADOS 323 -#define HOENN_DEX_CROBAT 65 -#define HOENN_DEX_CHINCHOU 181 -#define HOENN_DEX_LANTURN 182 -#define HOENN_DEX_PICHU 155 -#define HOENN_DEX_CLEFFA 324 -#define HOENN_DEX_IGGLYBUFF 137 -#define HOENN_DEX_TOGEPI 325 -#define HOENN_DEX_TOGETIC 326 -#define HOENN_DEX_NATU 162 -#define HOENN_DEX_XATU 163 -#define HOENN_DEX_MAREEP 327 -#define HOENN_DEX_FLAAFFY 328 -#define HOENN_DEX_AMPHAROS 329 -#define HOENN_DEX_BELLOSSOM 91 -#define HOENN_DEX_MARILL 55 -#define HOENN_DEX_AZUMARILL 56 -#define HOENN_DEX_SUDOWOODO 330 -#define HOENN_DEX_POLITOED 331 -#define HOENN_DEX_HOPPIP 332 -#define HOENN_DEX_SKIPLOOM 333 -#define HOENN_DEX_JUMPLUFF 334 -#define HOENN_DEX_AIPOM 335 -#define HOENN_DEX_SUNKERN 336 -#define HOENN_DEX_SUNFLORA 337 -#define HOENN_DEX_YANMA 338 -#define HOENN_DEX_WOOPER 339 -#define HOENN_DEX_QUAGSIRE 340 -#define HOENN_DEX_ESPEON 341 -#define HOENN_DEX_UMBREON 342 -#define HOENN_DEX_MURKROW 343 -#define HOENN_DEX_SLOWKING 344 -#define HOENN_DEX_MISDREAVUS 345 -#define HOENN_DEX_UNOWN 346 -#define HOENN_DEX_WOBBUFFET 161 -#define HOENN_DEX_GIRAFARIG 164 -#define HOENN_DEX_PINECO 347 -#define HOENN_DEX_FORRETRESS 348 -#define HOENN_DEX_DUNSPARCE 349 -#define HOENN_DEX_GLIGAR 350 -#define HOENN_DEX_STEELIX 351 -#define HOENN_DEX_SNUBBULL 352 -#define HOENN_DEX_GRANBULL 353 -#define HOENN_DEX_QWILFISH 354 -#define HOENN_DEX_SCIZOR 355 -#define HOENN_DEX_SHUCKLE 356 -#define HOENN_DEX_HERACROSS 168 -#define HOENN_DEX_SNEASEL 357 -#define HOENN_DEX_TEDDIURSA 358 -#define HOENN_DEX_URSARING 359 -#define HOENN_DEX_SLUGMA 103 -#define HOENN_DEX_MAGCARGO 104 -#define HOENN_DEX_SWINUB 360 -#define HOENN_DEX_PILOSWINE 361 -#define HOENN_DEX_CORSOLA 180 -#define HOENN_DEX_REMORAID 362 -#define HOENN_DEX_OCTILLERY 363 -#define HOENN_DEX_DELIBIRD 364 -#define HOENN_DEX_MANTINE 365 -#define HOENN_DEX_SKARMORY 115 -#define HOENN_DEX_HOUNDOUR 366 -#define HOENN_DEX_HOUNDOOM 367 -#define HOENN_DEX_KINGDRA 186 -#define HOENN_DEX_PHANPY 165 -#define HOENN_DEX_DONPHAN 166 -#define HOENN_DEX_PORYGON2 368 -#define HOENN_DEX_STANTLER 369 -#define HOENN_DEX_SMEARGLE 370 -#define HOENN_DEX_TYROGUE 371 -#define HOENN_DEX_HITMONTOP 372 -#define HOENN_DEX_SMOOCHUM 373 -#define HOENN_DEX_ELEKID 374 -#define HOENN_DEX_MAGBY 375 -#define HOENN_DEX_MILTANK 376 -#define HOENN_DEX_BLISSEY 377 -#define HOENN_DEX_RAIKOU 378 -#define HOENN_DEX_ENTEI 379 -#define HOENN_DEX_SUICUNE 380 -#define HOENN_DEX_LARVITAR 381 -#define HOENN_DEX_PUPITAR 382 -#define HOENN_DEX_TYRANITAR 383 -#define HOENN_DEX_LUGIA 384 -#define HOENN_DEX_HO_OH 385 -#define HOENN_DEX_CELEBI 386 +#define HOENN_DEX_NONE 0 +#define HOENN_DEX_TREECKO 1 +#define HOENN_DEX_GROVYLE 2 +#define HOENN_DEX_SCEPTILE 3 +#define HOENN_DEX_TORCHIC 4 +#define HOENN_DEX_COMBUSKEN 5 +#define HOENN_DEX_BLAZIKEN 6 +#define HOENN_DEX_MUDKIP 7 +#define HOENN_DEX_MARSHTOMP 8 +#define HOENN_DEX_SWAMPERT 9 +#define HOENN_DEX_POOCHYENA 10 +#define HOENN_DEX_MIGHTYENA 11 +#define HOENN_DEX_ZIGZAGOON 12 +#define HOENN_DEX_LINOONE 13 +#define HOENN_DEX_WURMPLE 14 +#define HOENN_DEX_SILCOON 15 +#define HOENN_DEX_BEAUTIFLY 16 +#define HOENN_DEX_CASCOON 17 +#define HOENN_DEX_DUSTOX 18 +#define HOENN_DEX_LOTAD 19 +#define HOENN_DEX_LOMBRE 20 +#define HOENN_DEX_LUDICOLO 21 +#define HOENN_DEX_SEEDOT 22 +#define HOENN_DEX_NUZLEAF 23 +#define HOENN_DEX_SHIFTRY 24 +#define HOENN_DEX_TAILLOW 25 +#define HOENN_DEX_SWELLOW 26 +#define HOENN_DEX_WINGULL 27 +#define HOENN_DEX_PELIPPER 28 +#define HOENN_DEX_RALTS 29 +#define HOENN_DEX_KIRLIA 30 +#define HOENN_DEX_GARDEVOIR 31 +#define HOENN_DEX_SURSKIT 32 +#define HOENN_DEX_MASQUERAIN 33 +#define HOENN_DEX_SHROOMISH 34 +#define HOENN_DEX_BRELOOM 35 +#define HOENN_DEX_SLAKOTH 36 +#define HOENN_DEX_VIGOROTH 37 +#define HOENN_DEX_SLAKING 38 +#define HOENN_DEX_ABRA 39 +#define HOENN_DEX_KADABRA 40 +#define HOENN_DEX_ALAKAZAM 41 +#define HOENN_DEX_NINCADA 42 +#define HOENN_DEX_NINJASK 43 +#define HOENN_DEX_SHEDINJA 44 +#define HOENN_DEX_WHISMUR 45 +#define HOENN_DEX_LOUDRED 46 +#define HOENN_DEX_EXPLOUD 47 +#define HOENN_DEX_MAKUHITA 48 +#define HOENN_DEX_HARIYAMA 49 +#define HOENN_DEX_GOLDEEN 50 +#define HOENN_DEX_SEAKING 51 +#define HOENN_DEX_MAGIKARP 52 +#define HOENN_DEX_GYARADOS 53 +#define HOENN_DEX_AZURILL 54 +#define HOENN_DEX_MARILL 55 +#define HOENN_DEX_AZUMARILL 56 +#define HOENN_DEX_GEODUDE 57 +#define HOENN_DEX_GRAVELER 58 +#define HOENN_DEX_GOLEM 59 +#define HOENN_DEX_NOSEPASS 60 +#define HOENN_DEX_SKITTY 61 +#define HOENN_DEX_DELCATTY 62 +#define HOENN_DEX_ZUBAT 63 +#define HOENN_DEX_GOLBAT 64 +#define HOENN_DEX_CROBAT 65 +#define HOENN_DEX_TENTACOOL 66 +#define HOENN_DEX_TENTACRUEL 67 +#define HOENN_DEX_SABLEYE 68 +#define HOENN_DEX_MAWILE 69 +#define HOENN_DEX_ARON 70 +#define HOENN_DEX_LAIRON 71 +#define HOENN_DEX_AGGRON 72 +#define HOENN_DEX_MACHOP 73 +#define HOENN_DEX_MACHOKE 74 +#define HOENN_DEX_MACHAMP 75 +#define HOENN_DEX_MEDITITE 76 +#define HOENN_DEX_MEDICHAM 77 +#define HOENN_DEX_ELECTRIKE 78 +#define HOENN_DEX_MANECTRIC 79 +#define HOENN_DEX_PLUSLE 80 +#define HOENN_DEX_MINUN 81 +#define HOENN_DEX_MAGNEMITE 82 +#define HOENN_DEX_MAGNETON 83 +#define HOENN_DEX_VOLTORB 84 +#define HOENN_DEX_ELECTRODE 85 +#define HOENN_DEX_VOLBEAT 86 +#define HOENN_DEX_ILLUMISE 87 +#define HOENN_DEX_ODDISH 88 +#define HOENN_DEX_GLOOM 89 +#define HOENN_DEX_VILEPLUME 90 +#define HOENN_DEX_BELLOSSOM 91 +#define HOENN_DEX_DODUO 92 +#define HOENN_DEX_DODRIO 93 +#define HOENN_DEX_ROSELIA 94 +#define HOENN_DEX_GULPIN 95 +#define HOENN_DEX_SWALOT 96 +#define HOENN_DEX_CARVANHA 97 +#define HOENN_DEX_SHARPEDO 98 +#define HOENN_DEX_WAILMER 99 +#define HOENN_DEX_WAILORD 100 +#define HOENN_DEX_NUMEL 101 +#define HOENN_DEX_CAMERUPT 102 +#define HOENN_DEX_SLUGMA 103 +#define HOENN_DEX_MAGCARGO 104 +#define HOENN_DEX_TORKOAL 105 +#define HOENN_DEX_GRIMER 106 +#define HOENN_DEX_MUK 107 +#define HOENN_DEX_KOFFING 108 +#define HOENN_DEX_WEEZING 109 +#define HOENN_DEX_SPOINK 110 +#define HOENN_DEX_GRUMPIG 111 +#define HOENN_DEX_SANDSHREW 112 +#define HOENN_DEX_SANDSLASH 113 +#define HOENN_DEX_SPINDA 114 +#define HOENN_DEX_SKARMORY 115 +#define HOENN_DEX_TRAPINCH 116 +#define HOENN_DEX_VIBRAVA 117 +#define HOENN_DEX_FLYGON 118 +#define HOENN_DEX_CACNEA 119 +#define HOENN_DEX_CACTURNE 120 +#define HOENN_DEX_SWABLU 121 +#define HOENN_DEX_ALTARIA 122 +#define HOENN_DEX_ZANGOOSE 123 +#define HOENN_DEX_SEVIPER 124 +#define HOENN_DEX_LUNATONE 125 +#define HOENN_DEX_SOLROCK 126 +#define HOENN_DEX_BARBOACH 127 +#define HOENN_DEX_WHISCASH 128 +#define HOENN_DEX_CORPHISH 129 +#define HOENN_DEX_CRAWDAUNT 130 +#define HOENN_DEX_BALTOY 131 +#define HOENN_DEX_CLAYDOL 132 +#define HOENN_DEX_LILEEP 133 +#define HOENN_DEX_CRADILY 134 +#define HOENN_DEX_ANORITH 135 +#define HOENN_DEX_ARMALDO 136 +#define HOENN_DEX_IGGLYBUFF 137 +#define HOENN_DEX_JIGGLYPUFF 138 +#define HOENN_DEX_WIGGLYTUFF 139 +#define HOENN_DEX_FEEBAS 140 +#define HOENN_DEX_MILOTIC 141 +#define HOENN_DEX_CASTFORM 142 +#define HOENN_DEX_STARYU 143 +#define HOENN_DEX_STARMIE 144 +#define HOENN_DEX_KECLEON 145 +#define HOENN_DEX_SHUPPET 146 +#define HOENN_DEX_BANETTE 147 +#define HOENN_DEX_DUSKULL 148 +#define HOENN_DEX_DUSCLOPS 149 +#define HOENN_DEX_TROPIUS 150 +#define HOENN_DEX_CHIMECHO 151 +#define HOENN_DEX_ABSOL 152 +#define HOENN_DEX_VULPIX 153 +#define HOENN_DEX_NINETALES 154 +#define HOENN_DEX_PICHU 155 +#define HOENN_DEX_PIKACHU 156 +#define HOENN_DEX_RAICHU 157 +#define HOENN_DEX_PSYDUCK 158 +#define HOENN_DEX_GOLDUCK 159 +#define HOENN_DEX_WYNAUT 160 +#define HOENN_DEX_WOBBUFFET 161 +#define HOENN_DEX_NATU 162 +#define HOENN_DEX_XATU 163 +#define HOENN_DEX_GIRAFARIG 164 +#define HOENN_DEX_PHANPY 165 +#define HOENN_DEX_DONPHAN 166 +#define HOENN_DEX_PINSIR 167 +#define HOENN_DEX_HERACROSS 168 +#define HOENN_DEX_RHYHORN 169 +#define HOENN_DEX_RHYDON 170 +#define HOENN_DEX_SNORUNT 171 +#define HOENN_DEX_GLALIE 172 +#define HOENN_DEX_SPHEAL 173 +#define HOENN_DEX_SEALEO 174 +#define HOENN_DEX_WALREIN 175 +#define HOENN_DEX_CLAMPERL 176 +#define HOENN_DEX_HUNTAIL 177 +#define HOENN_DEX_GOREBYSS 178 +#define HOENN_DEX_RELICANTH 179 +#define HOENN_DEX_CORSOLA 180 +#define HOENN_DEX_CHINCHOU 181 +#define HOENN_DEX_LANTURN 182 +#define HOENN_DEX_LUVDISC 183 +#define HOENN_DEX_HORSEA 184 +#define HOENN_DEX_SEADRA 185 +#define HOENN_DEX_KINGDRA 186 +#define HOENN_DEX_BAGON 187 +#define HOENN_DEX_SHELGON 188 +#define HOENN_DEX_SALAMENCE 189 +#define HOENN_DEX_BELDUM 190 +#define HOENN_DEX_METANG 191 +#define HOENN_DEX_METAGROSS 192 +#define HOENN_DEX_REGIROCK 193 +#define HOENN_DEX_REGICE 194 +#define HOENN_DEX_REGISTEEL 195 +#define HOENN_DEX_LATIAS 196 +#define HOENN_DEX_LATIOS 197 +#define HOENN_DEX_KYOGRE 198 +#define HOENN_DEX_GROUDON 199 +#define HOENN_DEX_RAYQUAZA 200 +#define HOENN_DEX_JIRACHI 201 +#define HOENN_DEX_DEOXYS 202 -#define HOENN_DEX_OLD_UNOWN_B 387 -#define HOENN_DEX_OLD_UNOWN_C 388 -#define HOENN_DEX_OLD_UNOWN_D 389 -#define HOENN_DEX_OLD_UNOWN_E 390 -#define HOENN_DEX_OLD_UNOWN_F 391 -#define HOENN_DEX_OLD_UNOWN_G 392 -#define HOENN_DEX_OLD_UNOWN_H 393 -#define HOENN_DEX_OLD_UNOWN_I 394 -#define HOENN_DEX_OLD_UNOWN_J 395 -#define HOENN_DEX_OLD_UNOWN_K 396 -#define HOENN_DEX_OLD_UNOWN_L 397 -#define HOENN_DEX_OLD_UNOWN_M 398 -#define HOENN_DEX_OLD_UNOWN_N 399 -#define HOENN_DEX_OLD_UNOWN_O 400 -#define HOENN_DEX_OLD_UNOWN_P 401 -#define HOENN_DEX_OLD_UNOWN_Q 402 -#define HOENN_DEX_OLD_UNOWN_R 403 -#define HOENN_DEX_OLD_UNOWN_S 404 -#define HOENN_DEX_OLD_UNOWN_T 405 -#define HOENN_DEX_OLD_UNOWN_U 406 -#define HOENN_DEX_OLD_UNOWN_V 407 -#define HOENN_DEX_OLD_UNOWN_W 408 -#define HOENN_DEX_OLD_UNOWN_X 409 -#define HOENN_DEX_OLD_UNOWN_Y 410 -#define HOENN_DEX_OLD_UNOWN_Z 411 +#define HOENN_DEX_COUNT HOENN_DEX_DEOXYS -#define HOENN_DEX_TREECKO 1 -#define HOENN_DEX_GROVYLE 2 -#define HOENN_DEX_SCEPTILE 3 -#define HOENN_DEX_TORCHIC 4 -#define HOENN_DEX_COMBUSKEN 5 -#define HOENN_DEX_BLAZIKEN 6 -#define HOENN_DEX_MUDKIP 7 -#define HOENN_DEX_MARSHTOMP 8 -#define HOENN_DEX_SWAMPERT 9 -#define HOENN_DEX_POOCHYENA 10 -#define HOENN_DEX_MIGHTYENA 11 -#define HOENN_DEX_ZIGZAGOON 12 -#define HOENN_DEX_LINOONE 13 -#define HOENN_DEX_WURMPLE 14 -#define HOENN_DEX_SILCOON 15 -#define HOENN_DEX_BEAUTIFLY 16 -#define HOENN_DEX_CASCOON 17 -#define HOENN_DEX_DUSTOX 18 -#define HOENN_DEX_LOTAD 19 -#define HOENN_DEX_LOMBRE 20 -#define HOENN_DEX_LUDICOLO 21 -#define HOENN_DEX_SEEDOT 22 -#define HOENN_DEX_NUZLEAF 23 -#define HOENN_DEX_SHIFTRY 24 -#define HOENN_DEX_NINCADA 42 -#define HOENN_DEX_NINJASK 43 -#define HOENN_DEX_SHEDINJA 44 -#define HOENN_DEX_TAILLOW 25 -#define HOENN_DEX_SWELLOW 26 -#define HOENN_DEX_SHROOMISH 34 -#define HOENN_DEX_BRELOOM 35 -#define HOENN_DEX_SPINDA 114 -#define HOENN_DEX_WINGULL 27 -#define HOENN_DEX_PELIPPER 28 -#define HOENN_DEX_SURSKIT 32 -#define HOENN_DEX_MASQUERAIN 33 -#define HOENN_DEX_WAILMER 99 -#define HOENN_DEX_WAILORD 100 -#define HOENN_DEX_SKITTY 61 -#define HOENN_DEX_DELCATTY 62 -#define HOENN_DEX_KECLEON 145 -#define HOENN_DEX_BALTOY 131 -#define HOENN_DEX_CLAYDOL 132 -#define HOENN_DEX_NOSEPASS 60 -#define HOENN_DEX_TORKOAL 105 -#define HOENN_DEX_SABLEYE 68 -#define HOENN_DEX_BARBOACH 127 -#define HOENN_DEX_WHISCASH 128 -#define HOENN_DEX_LUVDISC 183 -#define HOENN_DEX_CORPHISH 129 -#define HOENN_DEX_CRAWDAUNT 130 -#define HOENN_DEX_FEEBAS 140 -#define HOENN_DEX_MILOTIC 141 -#define HOENN_DEX_CARVANHA 97 -#define HOENN_DEX_SHARPEDO 98 -#define HOENN_DEX_TRAPINCH 116 -#define HOENN_DEX_VIBRAVA 117 -#define HOENN_DEX_FLYGON 118 -#define HOENN_DEX_MAKUHITA 48 -#define HOENN_DEX_HARIYAMA 49 -#define HOENN_DEX_ELECTRIKE 78 -#define HOENN_DEX_MANECTRIC 79 -#define HOENN_DEX_NUMEL 101 -#define HOENN_DEX_CAMERUPT 102 -#define HOENN_DEX_SPHEAL 173 -#define HOENN_DEX_SEALEO 174 -#define HOENN_DEX_WALREIN 175 -#define HOENN_DEX_CACNEA 119 -#define HOENN_DEX_CACTURNE 120 -#define HOENN_DEX_SNORUNT 171 -#define HOENN_DEX_GLALIE 172 -#define HOENN_DEX_LUNATONE 125 -#define HOENN_DEX_SOLROCK 126 -#define HOENN_DEX_AZURILL 54 -#define HOENN_DEX_SPOINK 110 -#define HOENN_DEX_GRUMPIG 111 -#define HOENN_DEX_PLUSLE 80 -#define HOENN_DEX_MINUN 81 -#define HOENN_DEX_MAWILE 69 -#define HOENN_DEX_MEDITITE 76 -#define HOENN_DEX_MEDICHAM 77 -#define HOENN_DEX_SWABLU 121 -#define HOENN_DEX_ALTARIA 122 -#define HOENN_DEX_WYNAUT 160 -#define HOENN_DEX_DUSKULL 148 -#define HOENN_DEX_DUSCLOPS 149 -#define HOENN_DEX_ROSELIA 94 -#define HOENN_DEX_SLAKOTH 36 -#define HOENN_DEX_VIGOROTH 37 -#define HOENN_DEX_SLAKING 38 -#define HOENN_DEX_GULPIN 95 -#define HOENN_DEX_SWALOT 96 -#define HOENN_DEX_TROPIUS 150 -#define HOENN_DEX_WHISMUR 45 -#define HOENN_DEX_LOUDRED 46 -#define HOENN_DEX_EXPLOUD 47 -#define HOENN_DEX_CLAMPERL 176 -#define HOENN_DEX_HUNTAIL 177 -#define HOENN_DEX_GOREBYSS 178 -#define HOENN_DEX_ABSOL 152 -#define HOENN_DEX_SHUPPET 146 -#define HOENN_DEX_BANETTE 147 -#define HOENN_DEX_SEVIPER 124 -#define HOENN_DEX_ZANGOOSE 123 -#define HOENN_DEX_RELICANTH 179 -#define HOENN_DEX_ARON 70 -#define HOENN_DEX_LAIRON 71 -#define HOENN_DEX_AGGRON 72 -#define HOENN_DEX_CASTFORM 142 -#define HOENN_DEX_VOLBEAT 86 -#define HOENN_DEX_ILLUMISE 87 -#define HOENN_DEX_LILEEP 133 -#define HOENN_DEX_CRADILY 134 -#define HOENN_DEX_ANORITH 135 -#define HOENN_DEX_ARMALDO 136 -#define HOENN_DEX_RALTS 29 -#define HOENN_DEX_KIRLIA 30 -#define HOENN_DEX_GARDEVOIR 31 -#define HOENN_DEX_BAGON 187 -#define HOENN_DEX_SHELGON 188 -#define HOENN_DEX_SALAMENCE 189 -#define HOENN_DEX_BELDUM 190 -#define HOENN_DEX_METANG 191 -#define HOENN_DEX_METAGROSS 192 -#define HOENN_DEX_REGIROCK 193 -#define HOENN_DEX_REGICE 194 -#define HOENN_DEX_REGISTEEL 195 -#define HOENN_DEX_KYOGRE 198 -#define HOENN_DEX_GROUDON 199 -#define HOENN_DEX_RAYQUAZA 200 -#define HOENN_DEX_LATIAS 196 -#define HOENN_DEX_LATIOS 197 -#define HOENN_DEX_JIRACHI 201 -#define HOENN_DEX_DEOXYS 202 -#define HOENN_DEX_CHIMECHO 151 +#define HOENN_DEX_BULBASAUR 203 +#define HOENN_DEX_IVYSAUR 204 +#define HOENN_DEX_VENUSAUR 205 +#define HOENN_DEX_CHARMANDER 206 +#define HOENN_DEX_CHARMELEON 207 +#define HOENN_DEX_CHARIZARD 208 +#define HOENN_DEX_SQUIRTLE 209 +#define HOENN_DEX_WARTORTLE 210 +#define HOENN_DEX_BLASTOISE 211 +#define HOENN_DEX_CATERPIE 212 +#define HOENN_DEX_METAPOD 213 +#define HOENN_DEX_BUTTERFREE 214 +#define HOENN_DEX_WEEDLE 215 +#define HOENN_DEX_KAKUNA 216 +#define HOENN_DEX_BEEDRILL 217 +#define HOENN_DEX_PIDGEY 218 +#define HOENN_DEX_PIDGEOTTO 219 +#define HOENN_DEX_PIDGEOT 220 +#define HOENN_DEX_RATTATA 221 +#define HOENN_DEX_RATICATE 222 +#define HOENN_DEX_SPEAROW 223 +#define HOENN_DEX_FEAROW 224 +#define HOENN_DEX_EKANS 225 +#define HOENN_DEX_ARBOK 226 +#define HOENN_DEX_NIDORAN_F 227 +#define HOENN_DEX_NIDORINA 228 +#define HOENN_DEX_NIDOQUEEN 229 +#define HOENN_DEX_NIDORAN_M 230 +#define HOENN_DEX_NIDORINO 231 +#define HOENN_DEX_NIDOKING 232 +#define HOENN_DEX_CLEFAIRY 233 +#define HOENN_DEX_CLEFABLE 234 +#define HOENN_DEX_PARAS 235 +#define HOENN_DEX_PARASECT 236 +#define HOENN_DEX_VENONAT 237 +#define HOENN_DEX_VENOMOTH 238 +#define HOENN_DEX_DIGLETT 239 +#define HOENN_DEX_DUGTRIO 240 +#define HOENN_DEX_MEOWTH 241 +#define HOENN_DEX_PERSIAN 242 +#define HOENN_DEX_MANKEY 243 +#define HOENN_DEX_PRIMEAPE 244 +#define HOENN_DEX_GROWLITHE 245 +#define HOENN_DEX_ARCANINE 246 +#define HOENN_DEX_POLIWAG 247 +#define HOENN_DEX_POLIWHIRL 248 +#define HOENN_DEX_POLIWRATH 249 +#define HOENN_DEX_BELLSPROUT 250 +#define HOENN_DEX_WEEPINBELL 251 +#define HOENN_DEX_VICTREEBEL 252 +#define HOENN_DEX_PONYTA 253 +#define HOENN_DEX_RAPIDASH 254 +#define HOENN_DEX_SLOWPOKE 255 +#define HOENN_DEX_SLOWBRO 256 +#define HOENN_DEX_FARFETCHD 257 +#define HOENN_DEX_SEEL 258 +#define HOENN_DEX_DEWGONG 259 +#define HOENN_DEX_SHELLDER 260 +#define HOENN_DEX_CLOYSTER 261 +#define HOENN_DEX_GASTLY 262 +#define HOENN_DEX_HAUNTER 263 +#define HOENN_DEX_GENGAR 264 +#define HOENN_DEX_ONIX 265 +#define HOENN_DEX_DROWZEE 266 +#define HOENN_DEX_HYPNO 267 +#define HOENN_DEX_KRABBY 268 +#define HOENN_DEX_KINGLER 269 +#define HOENN_DEX_EXEGGCUTE 270 +#define HOENN_DEX_EXEGGUTOR 271 +#define HOENN_DEX_CUBONE 272 +#define HOENN_DEX_MAROWAK 273 +#define HOENN_DEX_HITMONLEE 274 +#define HOENN_DEX_HITMONCHAN 275 +#define HOENN_DEX_LICKITUNG 276 +#define HOENN_DEX_CHANSEY 277 +#define HOENN_DEX_TANGELA 278 +#define HOENN_DEX_KANGASKHAN 279 +#define HOENN_DEX_MR_MIME 280 +#define HOENN_DEX_SCYTHER 281 +#define HOENN_DEX_JYNX 282 +#define HOENN_DEX_ELECTABUZZ 283 +#define HOENN_DEX_MAGMAR 284 +#define HOENN_DEX_TAUROS 285 +#define HOENN_DEX_LAPRAS 286 +#define HOENN_DEX_DITTO 287 +#define HOENN_DEX_EEVEE 288 +#define HOENN_DEX_VAPOREON 289 +#define HOENN_DEX_JOLTEON 290 +#define HOENN_DEX_FLAREON 291 +#define HOENN_DEX_PORYGON 292 +#define HOENN_DEX_OMANYTE 293 +#define HOENN_DEX_OMASTAR 294 +#define HOENN_DEX_KABUTO 295 +#define HOENN_DEX_KABUTOPS 296 +#define HOENN_DEX_AERODACTYL 297 +#define HOENN_DEX_SNORLAX 298 +#define HOENN_DEX_ARTICUNO 299 +#define HOENN_DEX_ZAPDOS 300 +#define HOENN_DEX_MOLTRES 301 +#define HOENN_DEX_DRATINI 302 +#define HOENN_DEX_DRAGONAIR 303 +#define HOENN_DEX_DRAGONITE 304 +#define HOENN_DEX_MEWTWO 305 +#define HOENN_DEX_MEW 306 +#define HOENN_DEX_CHIKORITA 307 +#define HOENN_DEX_BAYLEEF 308 +#define HOENN_DEX_MEGANIUM 309 +#define HOENN_DEX_CYNDAQUIL 310 +#define HOENN_DEX_QUILAVA 311 +#define HOENN_DEX_TYPHLOSION 312 +#define HOENN_DEX_TOTODILE 313 +#define HOENN_DEX_CROCONAW 314 +#define HOENN_DEX_FERALIGATR 315 +#define HOENN_DEX_SENTRET 316 +#define HOENN_DEX_FURRET 317 +#define HOENN_DEX_HOOTHOOT 318 +#define HOENN_DEX_NOCTOWL 319 +#define HOENN_DEX_LEDYBA 320 +#define HOENN_DEX_LEDIAN 321 +#define HOENN_DEX_SPINARAK 322 +#define HOENN_DEX_ARIADOS 323 +#define HOENN_DEX_CLEFFA 324 +#define HOENN_DEX_TOGEPI 325 +#define HOENN_DEX_TOGETIC 326 +#define HOENN_DEX_MAREEP 327 +#define HOENN_DEX_FLAAFFY 328 +#define HOENN_DEX_AMPHAROS 329 +#define HOENN_DEX_SUDOWOODO 330 +#define HOENN_DEX_POLITOED 331 +#define HOENN_DEX_HOPPIP 332 +#define HOENN_DEX_SKIPLOOM 333 +#define HOENN_DEX_JUMPLUFF 334 +#define HOENN_DEX_AIPOM 335 +#define HOENN_DEX_SUNKERN 336 +#define HOENN_DEX_SUNFLORA 337 +#define HOENN_DEX_YANMA 338 +#define HOENN_DEX_WOOPER 339 +#define HOENN_DEX_QUAGSIRE 340 +#define HOENN_DEX_ESPEON 341 +#define HOENN_DEX_UMBREON 342 +#define HOENN_DEX_MURKROW 343 +#define HOENN_DEX_SLOWKING 344 +#define HOENN_DEX_MISDREAVUS 345 +#define HOENN_DEX_UNOWN 346 +#define HOENN_DEX_PINECO 347 +#define HOENN_DEX_FORRETRESS 348 +#define HOENN_DEX_DUNSPARCE 349 +#define HOENN_DEX_GLIGAR 350 +#define HOENN_DEX_STEELIX 351 +#define HOENN_DEX_SNUBBULL 352 +#define HOENN_DEX_GRANBULL 353 +#define HOENN_DEX_QWILFISH 354 +#define HOENN_DEX_SCIZOR 355 +#define HOENN_DEX_SHUCKLE 356 +#define HOENN_DEX_SNEASEL 357 +#define HOENN_DEX_TEDDIURSA 358 +#define HOENN_DEX_URSARING 359 +#define HOENN_DEX_SWINUB 360 +#define HOENN_DEX_PILOSWINE 361 +#define HOENN_DEX_REMORAID 362 +#define HOENN_DEX_OCTILLERY 363 +#define HOENN_DEX_DELIBIRD 364 +#define HOENN_DEX_MANTINE 365 +#define HOENN_DEX_HOUNDOUR 366 +#define HOENN_DEX_HOUNDOOM 367 +#define HOENN_DEX_PORYGON2 368 +#define HOENN_DEX_STANTLER 369 +#define HOENN_DEX_SMEARGLE 370 +#define HOENN_DEX_TYROGUE 371 +#define HOENN_DEX_HITMONTOP 372 +#define HOENN_DEX_SMOOCHUM 373 +#define HOENN_DEX_ELEKID 374 +#define HOENN_DEX_MAGBY 375 +#define HOENN_DEX_MILTANK 376 +#define HOENN_DEX_BLISSEY 377 +#define HOENN_DEX_RAIKOU 378 +#define HOENN_DEX_ENTEI 379 +#define HOENN_DEX_SUICUNE 380 +#define HOENN_DEX_LARVITAR 381 +#define HOENN_DEX_PUPITAR 382 +#define HOENN_DEX_TYRANITAR 383 +#define HOENN_DEX_LUGIA 384 +#define HOENN_DEX_HO_OH 385 +#define HOENN_DEX_CELEBI 386 + +#define HOENN_DEX_OLD_UNOWN_B 387 +#define HOENN_DEX_OLD_UNOWN_C 388 +#define HOENN_DEX_OLD_UNOWN_D 389 +#define HOENN_DEX_OLD_UNOWN_E 390 +#define HOENN_DEX_OLD_UNOWN_F 391 +#define HOENN_DEX_OLD_UNOWN_G 392 +#define HOENN_DEX_OLD_UNOWN_H 393 +#define HOENN_DEX_OLD_UNOWN_I 394 +#define HOENN_DEX_OLD_UNOWN_J 395 +#define HOENN_DEX_OLD_UNOWN_K 396 +#define HOENN_DEX_OLD_UNOWN_L 397 +#define HOENN_DEX_OLD_UNOWN_M 398 +#define HOENN_DEX_OLD_UNOWN_N 399 +#define HOENN_DEX_OLD_UNOWN_O 400 +#define HOENN_DEX_OLD_UNOWN_P 401 +#define HOENN_DEX_OLD_UNOWN_Q 402 +#define HOENN_DEX_OLD_UNOWN_R 403 +#define HOENN_DEX_OLD_UNOWN_S 404 +#define HOENN_DEX_OLD_UNOWN_T 405 +#define HOENN_DEX_OLD_UNOWN_U 406 +#define HOENN_DEX_OLD_UNOWN_V 407 +#define HOENN_DEX_OLD_UNOWN_W 408 +#define HOENN_DEX_OLD_UNOWN_X 409 +#define HOENN_DEX_OLD_UNOWN_Y 410 +#define HOENN_DEX_OLD_UNOWN_Z 411 #endif // GUARD_CONSTANTS_SPECIES_H 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/decoration.h b/include/decoration.h index eed930356..b00dd42f1 100644 --- a/include/decoration.h +++ b/include/decoration.h @@ -52,14 +52,6 @@ struct Decoration const u16 *tiles; }; -struct DecorationPCContext -{ - u8 *items; - u8 *pos; - u8 size; - u8 isPlayerRoom; -}; - extern const struct Decoration gDecorations[]; extern EWRAM_DATA u8 *gCurDecorationItems; extern EWRAM_DATA u8 gCurDecorationIndex; diff --git a/include/decoration_inventory.h b/include/decoration_inventory.h index 7362c2da2..f43b91d7a 100644 --- a/include/decoration_inventory.h +++ b/include/decoration_inventory.h @@ -12,10 +12,10 @@ extern struct DecorationInventory gDecorationInventories[]; void SetDecorationInventoriesPointers(void); void ClearDecorationInventories(void); s8 GetFirstEmptyDecorSlot(u8 category); -u8 CheckHasDecoration(u8); -u8 DecorationAdd(u8); -u8 DecorationCheckSpace(u8); -s8 DecorationRemove(u8); +u8 CheckHasDecoration(u8 decor); +u8 DecorationAdd(u8 decor); +u8 DecorationCheckSpace(u8 decor); +s8 DecorationRemove(u8 decor); void CondenseDecorationsInCategory(u8 category); u8 GetNumOwnedDecorationsInCategory(u8 category); u8 GetNumOwnedDecorations(void); diff --git a/include/digit_obj_util.h b/include/digit_obj_util.h new file mode 100644 index 000000000..aca97e2c7 --- /dev/null +++ b/include/digit_obj_util.h @@ -0,0 +1,26 @@ +#ifndef GUARD_DIGIT_OBJ_UTIL_H +#define GUARD_DIGIT_OBJ_UTIL_H + +struct DigitObjUtilTemplate +{ + u8 strConvMode:2; + u8 shape:2; + u8 size:2; + u8 priority:2; + u8 oamCount; + u8 xDelta; + s16 x; + s16 y; + const struct SpriteSheet *spriteSheet; + const struct SpritePalette *spritePal; +}; + +bool32 DigitObjUtil_Init(u32 count); +void DigitObjUtil_Free(void); +bool32 DigitObjUtil_CreatePrinter(u32 id, s32 num, const struct DigitObjUtilTemplate *template); +void DigitObjUtil_PrintNumOn(u32 id, s32 arg1); +void DigitObjUtil_DeletePrinter(u32 id); +void DigitObjUtil_HideOrShow(u32 id, bool32 arg1); +u8 GetTilesPerImage(u32 shape, u32 size); + +#endif // GUARD_DIGIT_OBJ_UTIL_H diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index 5e5a2361f..1dbe171bc 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -48,7 +48,7 @@ bool8 PartyHasMonWithSurf(void); bool8 IsPlayerFacingSurfableFishableWater(void); bool8 IsPlayerSurfingNorth(void); void sub_808C228(u8 direction); -u8 sub_808BCD0(void); +u8 GetPlayerAvatarFlags(void); void sub_808B578(void); u8 GetFRLGAvatarGraphicsIdByGender(u8); u8 GetRSAvatarGraphicsIdByGender(u8); diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index af2be9c77..2e451a368 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -304,7 +304,7 @@ enum struct PlayerAvatar { /*0x00*/ u8 flags; - /*0x01*/ u8 unk1; // used to be named bike, but its definitely not that. seems to be some transition flags + /*0x01*/ u8 transitionFlags; // used to be named bike, but its definitely not that. seems to be some transition flags /*0x02*/ u8 runningState; // this is a static running state. 00 is not moving, 01 is turn direction, 02 is moving. /*0x03*/ u8 tileTransitionState; // this is a transition running state: 00 is not moving, 01 is transition between tiles, 02 means you are on the frame in which you have centered on a tile but are about to keep moving, even if changing directions. 2 is also used for a ledge hop, since you are transitioning. /*0x04*/ u8 spriteId; diff --git a/include/global.h b/include/global.h index ddeec579f..0587e964f 100644 --- a/include/global.h +++ b/include/global.h @@ -643,7 +643,7 @@ struct MauvilleManHipster struct MauvilleOldManTrader { u8 id; - u8 decorIds[NUM_TRADER_ITEMS]; + u8 decorations[NUM_TRADER_ITEMS]; u8 playerNames[NUM_TRADER_ITEMS][11]; u8 alreadyTraded; u8 language[NUM_TRADER_ITEMS]; @@ -934,16 +934,16 @@ struct SaveBlock1 /*0x159C*/ u32 gameStats[NUM_GAME_STATS]; /*0x169C*/ struct BerryTree berryTrees[BERRY_TREES_COUNT]; /*0x1A9C*/ struct SecretBase secretBases[SECRET_BASES_COUNT]; - /*0x271C*/ u8 playerRoomDecor[DECOR_MAX_PLAYERS_HOUSE]; - /*0x2728*/ u8 playerRoomDecorPos[DECOR_MAX_PLAYERS_HOUSE]; - /*0x2734*/ u8 decorDesk[10]; - /*0x273E*/ u8 decorChair[10]; - /*0x2748*/ u8 decorPlant[10]; - /*0x2752*/ u8 decorOrnament[30]; - /*0x2770*/ u8 decorMat[30]; - /*0x278E*/ u8 decorPoster[10]; - /*0x2798*/ u8 decorDoll[40]; - /*0x27C0*/ u8 decorCushion[10]; + /*0x271C*/ u8 playerRoomDecorations[DECOR_MAX_PLAYERS_HOUSE]; + /*0x2728*/ u8 playerRoomDecorationPositions[DECOR_MAX_PLAYERS_HOUSE]; + /*0x2734*/ u8 decorationDesks[10]; + /*0x273E*/ u8 decorationChairs[10]; + /*0x2748*/ u8 decorationPlants[10]; + /*0x2752*/ u8 decorationOrnaments[30]; + /*0x2770*/ u8 decorationMats[30]; + /*0x278E*/ u8 decorationPosters[10]; + /*0x2798*/ u8 decorationDolls[40]; + /*0x27C0*/ u8 decorationCushions[10]; /*0x27CA*/ u8 padding_27CA[2]; /*0x27CC*/ TVShow tvShows[TV_SHOWS_COUNT]; /*0x2B50*/ PokeNews pokeNews[POKE_NEWS_COUNT]; diff --git a/include/graphics.h b/include/graphics.h index 60343548f..5a5c984da 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -3282,25 +3282,24 @@ extern const u32 gBattleTerrainPalette_StadiumDrake[]; extern const u32 gBattleTerrainPalette_StadiumWallace[]; // pokedex -extern const u32 gPokedexMenu2_Gfx[]; -extern const u16 gPokedexText_Pal[]; +extern const u32 gPokedexInterface_Gfx[]; +extern const u16 gPokedexBgHoenn_Pal[]; extern const u32 gPokedexMenu_Gfx[]; -extern const u8 gPokedexTilemap_Main[]; -extern const u8 gPokedexTilemap_MainUnderlay[]; -extern const u8 gPokedexTilemap_StartMenu1[]; -extern const u8 gPokedexTilemap_StartMenu2[]; -extern const u16 gPokedexHoennBg_Pal[]; -extern const u16 gPokedexText_Pal[]; -extern const u16 gPokedexNationalBg_Pal[]; -extern const u8 gPokedexTilemap_DescriptionScreen[]; -extern const u8 gPokedexTilemap_CryScreen[]; -extern const u8 gPokedexTilemap_SizeScreen[]; -extern const u8 gPokedexTilemap_ScreenSelectBar1[]; -extern const u8 gPokedexTilemap_ScreenSelectBar2[]; -extern const u16 gPokedexCaughtScreenFade_Pal[]; +extern const u8 gPokedexList_Tilemap[]; +extern const u8 gPokedexListUnderlay_Tilemap[]; +extern const u8 gPokedexStartMenuMain_Tilemap[]; +extern const u8 gPokedexStartMenuSearchResults_Tilemap[]; +extern const u16 gPokedexSearchResults_Pal[]; +extern const u16 gPokedexBgNational_Pal[]; +extern const u8 gPokedexInfoScreen_Tilemap[]; +extern const u8 gPokedexCryScreen_Tilemap[]; +extern const u8 gPokedexSizeScreen_Tilemap[]; +extern const u8 gPokedexScreenSelectBarMain_Tilemap[]; +extern const u8 gPokedexScreenSelectBarSubmenu_Tilemap[]; +extern const u16 gPokedexCaughtScreen_Pal[]; extern const u32 gPokedexSearchMenu_Gfx[]; -extern const u32 gPokedexSearch2_Tilemap[]; -extern const u32 gPokedexSearch1_Tilemap[]; +extern const u32 gPokedexSearchMenuHoenn_Tilemap[]; +extern const u32 gPokedexSearchMenuNational_Tilemap[]; extern const u16 gPokedexSearchMenu_Pal[]; // berry tag screen diff --git a/include/minigame_countdown.h b/include/minigame_countdown.h new file mode 100644 index 000000000..930205218 --- /dev/null +++ b/include/minigame_countdown.h @@ -0,0 +1,7 @@ +#ifndef GUARD_MINIGAME_COUNTDOWN_H +#define GUARD_MINIGAME_COUNTDOWN_H + +void StartMinigameCountdown(u16 tilesTag, u16 palTag, s16 x, s16 y, u8 subpriority); +bool32 IsMinigameCountdownRunning(void); + +#endif //GUARD_MINIGAME_COUNTDOWN_H diff --git a/include/party_menu.h b/include/party_menu.h index 126931762..7f51d08c9 100644 --- a/include/party_menu.h +++ b/include/party_menu.h @@ -24,8 +24,8 @@ extern struct PartyMenu gPartyMenu; extern bool8 gPartyMenuUseExitCallback; extern u8 gSelectedMonPartyId; extern MainCallback gPostMenuFieldCallback; -extern u8 gSelectedOrderFromParty[4]; -extern u8 gBattlePartyCurrentOrder[3]; +extern u8 gSelectedOrderFromParty[MAX_FRONTIER_PARTY_SIZE]; +extern u8 gBattlePartyCurrentOrder[PARTY_SIZE / 2]; extern void (*gItemUseCB)(u8, TaskFunc); diff --git a/include/pokedex.h b/include/pokedex.h index 532c823ee..36a48da1e 100644 --- a/include/pokedex.h +++ b/include/pokedex.h @@ -2,11 +2,7 @@ #define GUARD_POKEDEX_H extern u8 gUnusedPokedexU8; -extern void (*gUnknown_030060B4)(void); - -#define KANTO_DEX_COUNT 151 -#define HOENN_DEX_COUNT 202 -#define NATIONAL_DEX_COUNT 386 +extern void (*gPokedexVBlankCB)(void); enum { @@ -39,12 +35,12 @@ void ResetPokedex(void); u16 GetPokedexHeightWeight(u16 dexNum, u8 data); u16 GetNationalPokedexCount(u8); u16 GetHoennPokedexCount(u8); -u8 CreateDexDisplayMonDataTask(u16 dexNum, u32 trainerId, u32 personality); +u8 DisplayCaughtMonDexPage(u16 dexNum, u32 otId, u32 personality); s8 GetSetPokedexFlag(u16 nationalNum, u8 caseId); u16 CreateMonSpriteFromNationalDexNumber(u16, s16, s16, u16); bool16 HasAllHoennMons(void); void ResetPokedexScrollPositions(void); bool16 HasAllMons(void); -void CB2_Pokedex(void); +void CB2_OpenPokedex(void); #endif // GUARD_POKEDEX_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/pokedex_cry_screen.h b/include/pokedex_cry_screen.h index 93f1b02a5..4d2043292 100755 --- a/include/pokedex_cry_screen.h +++ b/include/pokedex_cry_screen.h @@ -1,10 +1,10 @@ #ifndef GUARD_POKEDEX_CRY_SCREEN_H #define GUARD_POKEDEX_CRY_SCREEN_H -struct CryRelatedStruct +struct CryScreenWindow { - u16 unk0; - u8 unk2; + u16 unk0; // Assigned to val that's never read + u8 unk2; // Never read u8 paletteNo; u8 xPos; u8 yPos; @@ -12,10 +12,10 @@ struct CryRelatedStruct extern u8 gDexCryScreenState; -bool8 sub_8145354(struct CryRelatedStruct*, u8); -void sub_814545C(u8); -void sub_8145534(u16); -bool8 sub_8145850(struct CryRelatedStruct*, u8); -void sub_8145914(void); +bool8 LoadCryWaveformWindow(struct CryScreenWindow*, u8); +void UpdateCryWaveformWindow(u8); +void CryScreenPlayButton(u16); +bool8 LoadCryMeter(struct CryScreenWindow*, u8); +void FreeCryScreen(void); #endif diff --git a/include/pokemon_jump.h b/include/pokemon_jump.h index dde59aac5..9cf65212f 100644 --- a/include/pokemon_jump.h +++ b/include/pokemon_jump.h @@ -8,7 +8,5 @@ bool32 IsSpeciesAllowedInPokemonJump(u16 species); void IsPokemonJumpSpeciesInParty(void); void ResetPokeJumpResults(void); void ShowPokemonJumpRecords(void); -void sub_802EB24(s16 tileTag, s16 palTag, s16 x, s16 y, u8 subpriority); -bool32 sub_802EB84(void); #endif // GUARD_POKEMON_JUMP_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/rom_8034C54.h b/include/rom_8034C54.h deleted file mode 100644 index 4da324dd1..000000000 --- a/include/rom_8034C54.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef GUARD_ROM_8034C54_H -#define GUARD_ROM_8034C54_H - -struct UnkStruct3 -{ - u8 field_0_0:2; - u8 shape:2; - u8 size:2; - u8 priority:2; - u8 field_1; - u8 xDelta; - s16 x; - s16 y; - const struct SpriteSheet *spriteSheet; - const struct SpritePalette *spritePal; -}; - -bool32 sub_8034C54(u32 count); -void sub_8034CC8(void); -bool32 sub_8034D14(u32 id, s32 arg1, const struct UnkStruct3 *arg2); -void sub_8035044(u32 id, s32 arg1); -void sub_80353DC(u32 id); -void sub_803547C(u32 id, bool32 arg1); -u8 sub_80355F8(u32 shape, u32 size); - -#endif // GUARD_ROM_8034C54_H diff --git a/include/trader.h b/include/trader.h index 25d72bd3b..409d0ba14 100644 --- a/include/trader.h +++ b/include/trader.h @@ -5,7 +5,7 @@ #ifndef GUARD_TRADER_H #define GUARD_TRADER_H -void sub_8133DA0(u8 taskId); +void DecorationItemsMenuAction_Trade(u8 taskId); void ExitTraderMenu(u8 taskId); void TraderSetup(void); void Trader_ResetFlag(void); 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 7eda77431..2762e2254 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -77,11 +77,12 @@ SECTIONS { src/berry_powder.o(.text); src/dodrio_berry_picking.o(.text); src/pokemon_jump.o(.text); + src/minigame_countdown.o(.text); src/rtc.o(.text); src/main_menu.o(.text); src/battle_controllers.o(.text); src/decompress.o(.text); - src/rom_8034C54.o(.text); + src/digit_obj_util.o(.text); src/battle_bg.o(.text); src/battle_main.o(.text); src/battle_util.o(.text); @@ -305,7 +306,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); @@ -461,10 +462,11 @@ SECTIONS { src/berry_powder.o(.rodata); src/dodrio_berry_picking.o(.rodata); src/pokemon_jump.o(.rodata); + src/minigame_countdown.o(.rodata); src/rtc.o(.rodata); src/main_menu.o(.rodata); src/battle_controllers.o(.rodata); - src/rom_8034C54.o(.rodata); + src/digit_obj_util.o(.rodata); src/data.o(.rodata); src/battle_bg.o(.rodata); src/battle_main.o(.rodata); @@ -660,7 +662,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/battle_anim_effects_2.c b/src/battle_anim_effects_2.c index 8b9edc138..e6ac7ffb2 100755 --- a/src/battle_anim_effects_2.c +++ b/src/battle_anim_effects_2.c @@ -79,8 +79,8 @@ static void AnimAngel(struct Sprite *); static void AnimPinkHeart(struct Sprite *); static void AnimDevil(struct Sprite *); static void AnimFurySwipes(struct Sprite *); -static void AnimMovmentWaves(struct Sprite *); -static void AnimMovmentWaves_Step(struct Sprite *); +static void AnimMovementWaves(struct Sprite *); +static void AnimMovementWaves_Step(struct Sprite *); static void AnimJaggedMusicNote(struct Sprite *); static void AnimJaggedMusicNote_Step(struct Sprite *); static void AnimPerishSongMusicNote2(struct Sprite *); @@ -1185,7 +1185,7 @@ const struct SpriteTemplate gMovementWavesSpriteTemplate = .anims = gMovementWavesAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = AnimMovmentWaves, + .callback = AnimMovementWaves, }; static const union AffineAnimCmd sAffineAnims_UproarDistortion[] = @@ -3628,7 +3628,7 @@ static void AnimFurySwipes(struct Sprite *sprite) } } -static void AnimMovmentWaves(struct Sprite *sprite) +static void AnimMovementWaves(struct Sprite *sprite) { if (!gBattleAnimArgs[2]) { @@ -3655,11 +3655,11 @@ static void AnimMovmentWaves(struct Sprite *sprite) sprite->data[0] = gBattleAnimArgs[2]; sprite->data[1] = gBattleAnimArgs[1]; StartSpriteAnim(sprite, sprite->data[1]); - sprite->callback = AnimMovmentWaves_Step; + sprite->callback = AnimMovementWaves_Step; } } -static void AnimMovmentWaves_Step(struct Sprite *sprite) +static void AnimMovementWaves_Step(struct Sprite *sprite) { if (sprite->animEnded) { diff --git a/src/battle_bg.c b/src/battle_bg.c index ac40051b4..bc30dfa84 100644 --- a/src/battle_bg.c +++ b/src/battle_bg.c @@ -691,6 +691,25 @@ static const struct BattleBackground gBattleTerrainTable[] = }, }; +static void sub_8035648(void); + +// Unused +static void sub_8035608(void) +{ + u8 spriteId; + + ResetSpriteData(); + spriteId = CreateSprite(&gUnknown_0831AC88, 0, 0, 0); + gSprites[spriteId].invisible = TRUE; + SetMainCallback2(sub_8035648); +} + +static void sub_8035648(void) +{ + AnimateSprites(); + BuildOamBuffer(); +} + void BattleInitBgsAndWindows(void) { ResetBgsAndClearDma3BusyFlags(0); diff --git a/src/battle_dome.c b/src/battle_dome.c index 3b2d0b317..850efea30 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -2578,7 +2578,7 @@ static void CreateDomeOpponentMons(u16 tournamentTrainerId) // Create mon if it was selected, starting from back for (i = FRONTIER_PARTY_SIZE - 1; i >= 0; i--) { - if (selectedMonBits & 4) + if (selectedMonBits & (1 << (FRONTIER_PARTY_SIZE - 1))) { CreateDomeOpponentMon(monsCount, tournamentTrainerId, i, otId); monsCount++; diff --git a/src/battle_main.c b/src/battle_main.c index da7116dbd..d860f87cb 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4011,7 +4011,7 @@ static void HandleTurnActionSelectionState(void) RecordedBattle_ClearBattlerAction(gActiveBattler, 1); gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT; *(gBattleStruct->selectionScriptFinished + gActiveBattler) = FALSE; - gBattleResources->bufferB[gActiveBattler][1] = 0; + gBattleResources->bufferB[gActiveBattler][1] = B_ACTION_USE_MOVE; *(gBattleStruct->stateIdAfterSelScript + gActiveBattler) = STATE_WAIT_ACTION_CHOSEN; return; } @@ -4146,7 +4146,7 @@ static void HandleTurnActionSelectionState(void) case STATE_SELECTION_SCRIPT_MAY_RUN: if (*(gBattleStruct->selectionScriptFinished + gActiveBattler)) { - if (gBattleResources->bufferB[gActiveBattler][1] == 13) + if (gBattleResources->bufferB[gActiveBattler][1] == B_ACTION_NOTHING_FAINTED) { gHitMarker |= HITMARKER_RUN; gChosenActionByBattler[gActiveBattler] = B_ACTION_RUN; diff --git a/src/battle_pike.c b/src/battle_pike.c index 9bc7254ec..6b31419a5 100644 --- a/src/battle_pike.c +++ b/src/battle_pike.c @@ -874,20 +874,20 @@ static bool8 TryInflictRandomStatus(void) { u8 j, i; u8 count; - u8 indices[3]; + u8 indices[FRONTIER_PARTY_SIZE]; u32 status; u16 species; bool8 statusChosen; struct Pokemon *mon; - for (i = 0; i < 3; i++) + for (i = 0; i < FRONTIER_PARTY_SIZE; i++) indices[i] = i; for (j = 0; j < 10; j++) { u8 temp, id; - i = Random() % 3; - id = Random() % 3; + i = Random() % FRONTIER_PARTY_SIZE; + id = Random() % FRONTIER_PARTY_SIZE; SWAP(indices[i], indices[id], temp); } @@ -921,7 +921,7 @@ static bool8 TryInflictRandomStatus(void) { status = sStatusFlags; j = 0; - for (i = 0; i < 3; i++) + for (i = 0; i < FRONTIER_PARTY_SIZE; i++) { mon = &gPlayerParty[indices[i]]; if (GetAilmentFromStatus(GetMonData(mon, MON_DATA_STATUS)) == AILMENT_NONE @@ -963,7 +963,7 @@ static bool8 TryInflictRandomStatus(void) } j = 0; - for (i = 0; i < 3; i++) + for (i = 0; i < FRONTIER_PARTY_SIZE; i++) { mon = &gPlayerParty[indices[i]]; if (GetAilmentFromStatus(GetMonData(mon, MON_DATA_STATUS)) == AILMENT_NONE @@ -995,7 +995,7 @@ static bool8 AtLeastOneHealthyMon(void) count = 3; healthyMonsCount = 0; - for (i = 0; i < 3; i++) + for (i = 0; i < FRONTIER_PARTY_SIZE; i++) { struct Pokemon *mon = &gPlayerParty[i]; if (GetAilmentFromStatus(GetMonData(mon, MON_DATA_STATUS)) == AILMENT_NONE @@ -1262,23 +1262,23 @@ static void Task_DoStatusInflictionScreenFlash(u8 taskId) static void TryHealMons(u8 healCount) { u8 j, i, k; - u8 indices[3]; + u8 indices[FRONTIER_PARTY_SIZE]; if (healCount == 0) return; - for (i = 0; i < 3; i++) + for (i = 0; i < FRONTIER_PARTY_SIZE; i++) indices[i] = i; for (k = 0; k < 10; k++) { u8 temp; - i = Random() % 3; - j = Random() % 3; + i = Random() % FRONTIER_PARTY_SIZE; + j = Random() % FRONTIER_PARTY_SIZE; SWAP(indices[i], indices[j], temp); } - for (i = 0; i < 3; i++) + for (i = 0; i < FRONTIER_PARTY_SIZE; i++) { bool32 canBeHealed = FALSE; struct Pokemon *mon = &gPlayerParty[indices[i]]; @@ -1483,7 +1483,7 @@ static bool8 AtLeastTwoAliveMons(void) mon = &gPlayerParty[0]; countDead = 0; - for (i = 0; i < 3; i++, mon++) + for (i = 0; i < FRONTIER_PARTY_SIZE; i++, mon++) { if (GetMonData(mon, MON_DATA_HP) == 0) countDead++; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 1e8676d3a..df12f1cec 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -10043,7 +10043,7 @@ static void Cmd_jumpifnopursuitswitchdmg(void) for (i = 0; i < gBattlersCount; i++) { if (gBattlerByTurnOrder[i] == gBattlerTarget) - gActionsByTurnOrder[i] = 11; + gActionsByTurnOrder[i] = B_ACTION_TRY_FINISH; } gCurrentMove = MOVE_PURSUIT; @@ -11184,7 +11184,7 @@ static void Cmd_pursuitrelated(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && !(gAbsentBattlerFlags & gBitTable[gActiveBattler]) - && gChosenActionByBattler[gActiveBattler] == 0 + && gChosenActionByBattler[gActiveBattler] == B_ACTION_USE_MOVE && gChosenMoveByBattler[gActiveBattler] == MOVE_PURSUIT) { gActionsByTurnOrder[gActiveBattler] = 11; @@ -11450,7 +11450,7 @@ static void Cmd_displaydexinfo(void) if (!gPaletteFade.active) { FreeAllWindowBuffers(); - gBattleCommunication[TASK_ID] = CreateDexDisplayMonDataTask(SpeciesToNationalPokedexNum(species), + gBattleCommunication[TASK_ID] = DisplayCaughtMonDexPage(SpeciesToNationalPokedexNum(species), gBattleMons[GetCatchingBattler()].otId, gBattleMons[GetCatchingBattler()].personality); gBattleCommunication[0]++; diff --git a/src/battle_tower.c b/src/battle_tower.c index bf7654ad5..0324ecbca 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -24,6 +24,7 @@ #include "tv.h" #include "battle_factory.h" #include "constants/apprentice.h" +#include "constants/battle_dome.h" #include "constants/battle_frontier.h" #include "constants/battle_frontier_mons.h" #include "constants/battle_tent_mons.h" @@ -2070,7 +2071,7 @@ void DoSpecialTrainerBattle(void) if (VarGet(VAR_FRONTIER_BATTLE_MODE) == FRONTIER_MODE_DOUBLES) gBattleTypeFlags |= BATTLE_TYPE_DOUBLE; if (gTrainerBattleOpponent_A == TRAINER_FRONTIER_BRAIN) - FillFrontierTrainerParty(2); + FillFrontierTrainerParty(DOME_BATTLE_PARTY_SIZE); CreateTask(Task_StartBattleAfterTransition, 1); sub_806E694(0); BattleTransition_StartOnField(sub_80B100C(3)); @@ -2255,12 +2256,12 @@ static void nullsub_116(void) static void GetApprenticeMultiPartnerParty(u16 trainerId) { s32 i, count; - u32 validSpecies[3]; + u32 validSpecies[MULTI_PARTY_SIZE]; u16 species1 = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES, NULL); u16 species2 = GetMonData(&gPlayerParty[1], MON_DATA_SPECIES, NULL); count = 0; - for (i = 0; i < 3; i++) + for (i = 0; i < MULTI_PARTY_SIZE; i++) { u16 apprenticeSpecies = gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].party[i].species; if (apprenticeSpecies != species1 && apprenticeSpecies != species2) @@ -2384,7 +2385,7 @@ static void LoadMultiPartnerCandidatesData(void) && gSaveBlock2Ptr->apprentices[i].lvlMode - 1 == lvlMode) { k = 0; - for (j = 0; j < 3; j++) + for (j = 0; j < MULTI_PARTY_SIZE; j++) { if (species1 != gSaveBlock2Ptr->apprentices[i].party[j].species && species2 != gSaveBlock2Ptr->apprentices[i].party[j].species) @@ -2992,26 +2993,26 @@ static void FillPartnerParty(u16 trainerId) if (trainerId == TRAINER_STEVEN_PARTNER) { - for (i = 0; i < 3; i++) + for (i = 0; i < MULTI_PARTY_SIZE; i++) { do { j = Random32(); } while (IsShinyOtIdPersonality(STEVEN_OTID, j) || sStevenMons[i].nature != GetNatureFromPersonality(j)); - CreateMon(&gPlayerParty[3 + i], + CreateMon(&gPlayerParty[MULTI_PARTY_SIZE + i], sStevenMons[i].species, sStevenMons[i].level, sStevenMons[i].fixedIV, TRUE, i, // BUG: personality was stored in the 'j' variable. As a result, Steven's pokemon do not have the intended natures. OT_ID_PRESET, STEVEN_OTID); for (j = 0; j < PARTY_SIZE; j++) - SetMonData(&gPlayerParty[3 + i], MON_DATA_HP_EV + j, &sStevenMons[i].evs[j]); + SetMonData(&gPlayerParty[MULTI_PARTY_SIZE + i], MON_DATA_HP_EV + j, &sStevenMons[i].evs[j]); for (j = 0; j < MAX_MON_MOVES; j++) - SetMonMoveSlot(&gPlayerParty[3 + i], sStevenMons[i].moves[j], j); - SetMonData(&gPlayerParty[3 + i], MON_DATA_OT_NAME, gTrainers[TRAINER_STEVEN].trainerName); + SetMonMoveSlot(&gPlayerParty[MULTI_PARTY_SIZE + i], sStevenMons[i].moves[j], j); + SetMonData(&gPlayerParty[MULTI_PARTY_SIZE + i], MON_DATA_OT_NAME, gTrainers[TRAINER_STEVEN].trainerName); j = MALE; - SetMonData(&gPlayerParty[3 + i], MON_DATA_OT_GENDER, &j); - CalculateMonStats(&gPlayerParty[3 + i]); + SetMonData(&gPlayerParty[MULTI_PARTY_SIZE + i], MON_DATA_OT_GENDER, &j); + CalculateMonStats(&gPlayerParty[MULTI_PARTY_SIZE + i]); } } else if (trainerId >= TRAINER_CUSTOM_PARTNER) @@ -3090,10 +3091,10 @@ static void FillPartnerParty(u16 trainerId) level = SetFacilityPtrsGetLevel(); ivs = GetFrontierTrainerFixedIvs(trainerId); otID = Random32(); - for (i = 0; i < 2; i++) + for (i = 0; i < FRONTIER_MULTI_PARTY_SIZE; i++) { monId = gSaveBlock2Ptr->frontier.trainerIds[i + 18]; - CreateMonWithEVSpreadNatureOTID(&gPlayerParty[3 + i], + CreateMonWithEVSpreadNatureOTID(&gPlayerParty[MULTI_PARTY_SIZE + i], gFacilityTrainerMons[monId].species, level, gFacilityTrainerMons[monId].nature, @@ -3103,23 +3104,23 @@ static void FillPartnerParty(u16 trainerId) friendship = MAX_FRIENDSHIP; for (j = 0; j < MAX_MON_MOVES; j++) { - SetMonMoveSlot(&gPlayerParty[3 + i], gFacilityTrainerMons[monId].moves[j], j); + SetMonMoveSlot(&gPlayerParty[MULTI_PARTY_SIZE + i], gFacilityTrainerMons[monId].moves[j], j); if (gFacilityTrainerMons[monId].moves[j] == MOVE_FRUSTRATION) friendship = 0; } - SetMonData(&gPlayerParty[3 + i], MON_DATA_FRIENDSHIP, &friendship); - SetMonData(&gPlayerParty[3 + i], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]); + SetMonData(&gPlayerParty[MULTI_PARTY_SIZE + i], MON_DATA_FRIENDSHIP, &friendship); + SetMonData(&gPlayerParty[MULTI_PARTY_SIZE + i], MON_DATA_HELD_ITEM, &gBattleFrontierHeldItems[gFacilityTrainerMons[monId].itemTableId]); for (j = 0; j < PLAYER_NAME_LENGTH + 1; j++) trainerName[j] = gFacilityTrainers[trainerId].trainerName[j]; - SetMonData(&gPlayerParty[3 + i], MON_DATA_OT_NAME, &trainerName); + SetMonData(&gPlayerParty[MULTI_PARTY_SIZE + i], MON_DATA_OT_NAME, &trainerName); j = IsFrontierTrainerFemale(trainerId); - SetMonData(&gPlayerParty[3 + i], MON_DATA_OT_GENDER, &j); + SetMonData(&gPlayerParty[MULTI_PARTY_SIZE + i], MON_DATA_OT_GENDER, &j); } } else if (trainerId < TRAINER_RECORD_MIXING_APPRENTICE) { trainerId -= TRAINER_RECORD_MIXING_FRIEND; - for (i = 0; i < 2; i++) + for (i = 0; i < FRONTIER_MULTI_PARTY_SIZE; i++) { struct EmeraldBattleTowerRecord *record = &gSaveBlock2Ptr->frontier.towerRecords[trainerId]; struct BattleTowerPokemon monData = record->party[gSaveBlock2Ptr->frontier.trainerIds[18 + i]]; @@ -3137,20 +3138,20 @@ static void FillPartnerParty(u16 trainerId) if (monData.nickname[0] == EXT_CTRL_CODE_BEGIN && monData.nickname[1] == EXT_CTRL_CODE_JPN) trainerName[5] = EOS; } - CreateBattleTowerMon2(&gPlayerParty[3 + i], &monData, TRUE); - SetMonData(&gPlayerParty[3 + i], MON_DATA_OT_NAME, trainerName); + CreateBattleTowerMon2(&gPlayerParty[MULTI_PARTY_SIZE + i], &monData, TRUE); + SetMonData(&gPlayerParty[MULTI_PARTY_SIZE + i], MON_DATA_OT_NAME, trainerName); j = IsFrontierTrainerFemale(trainerId + TRAINER_RECORD_MIXING_FRIEND); - SetMonData(&gPlayerParty[3 + i], MON_DATA_OT_GENDER, &j); + SetMonData(&gPlayerParty[MULTI_PARTY_SIZE + i], MON_DATA_OT_GENDER, &j); } } else { trainerId -= TRAINER_RECORD_MIXING_APPRENTICE; - for (i = 0; i < 2; i++) + for (i = 0; i < FRONTIER_MULTI_PARTY_SIZE; i++) { - CreateApprenticeMon(&gPlayerParty[3 + i], &gSaveBlock2Ptr->apprentices[trainerId], gSaveBlock2Ptr->frontier.trainerIds[18 + i]); + CreateApprenticeMon(&gPlayerParty[MULTI_PARTY_SIZE + i], &gSaveBlock2Ptr->apprentices[trainerId], gSaveBlock2Ptr->frontier.trainerIds[18 + i]); j = IsFrontierTrainerFemale(trainerId + TRAINER_RECORD_MIXING_APPRENTICE); - SetMonData(&gPlayerParty[3 + i], MON_DATA_OT_GENDER, &j); + SetMonData(&gPlayerParty[MULTI_PARTY_SIZE + i], MON_DATA_OT_GENDER, &j); } } } @@ -3461,7 +3462,7 @@ static void SetNextBattleTentOpponent(void) static void FillTentTrainerParty_(u16 trainerId, u8 firstMonId, u8 monCount) { s32 i, j; - u16 chosenMonIndices[4]; + u16 chosenMonIndices[MAX_FRONTIER_PARTY_SIZE]; u8 friendship; u8 level = SetTentPtrsGetLevel(); u8 fixedIV = 0; diff --git a/src/berry_crush.c b/src/berry_crush.c index 542888631..a67d1548e 100755 --- a/src/berry_crush.c +++ b/src/berry_crush.c @@ -19,9 +19,9 @@ #include "menu.h" #include "overworld.h" #include "palette.h" -#include "pokemon_jump.h" +#include "minigame_countdown.h" #include "random.h" -#include "rom_8034C54.h" +#include "digit_obj_util.h" #include "save.h" #include "scanline_effect.h" #include "script.h" @@ -714,14 +714,14 @@ static const struct SpriteTemplate gUnknown_082F436C = .callback = SpriteCallbackDummy }; -static const struct UnkStruct3 gUnknown_082F4384[] = +static const struct DigitObjUtilTemplate gUnknown_082F4384[] = { { - .field_0_0 = 1, + .strConvMode = 1, .shape = 2, .size = 0, .priority = 0, - .field_1 = 2, + .oamCount = 2, .xDelta = 8, .x = 156, .y = 0, @@ -729,11 +729,11 @@ static const struct UnkStruct3 gUnknown_082F4384[] = .spritePal = gUnknown_082F422C, }, { - .field_0_0 = 0, + .strConvMode = 0, .shape = 2, .size = 0, .priority = 0, - .field_1 = 2, + .oamCount = 2, .xDelta = 8, .x = 180, .y = 0, @@ -741,11 +741,11 @@ static const struct UnkStruct3 gUnknown_082F4384[] = .spritePal = gUnknown_082F422C, }, { - .field_0_0 = 0, + .strConvMode = 0, .shape = 2, .size = 0, .priority = 0, - .field_1 = 2, + .oamCount = 2, .xDelta = 8, .x = 204, .y = 0, @@ -1036,7 +1036,7 @@ int sub_802104C(void) case 1: CpuFill16(0, (void *)OAM, OAM_SIZE); gReservedSpritePaletteCount = 0; - sub_8034C54(3); + DigitObjUtil_Init(3); break; case 2: ResetPaletteFade(); @@ -1165,7 +1165,7 @@ int sub_802130C(void) case 6: DestroyWirelessStatusIndicatorSprite(); sub_8022960(var0); - sub_8034CC8(); + DigitObjUtil_Free(); break; case 7: var0->unkC = 0; @@ -1701,18 +1701,18 @@ void ShowBerryCrushRankings(void) void sub_8022524(struct BerryCrushGame_138 *r4, u16 r1) { sub_8021944(r4, r1); - sub_8035044(0, r4->unk4); - sub_8035044(1, r4->unk6); - sub_8035044(2, r4->unk8); + DigitObjUtil_PrintNumOn(0, r4->unk4); + DigitObjUtil_PrintNumOn(1, r4->unk6); + DigitObjUtil_PrintNumOn(2, r4->unk8); } void sub_8022554(struct BerryCrushGame_138 *r0) { r0->unk78[0]->invisible = TRUE; r0->unk78[1]->invisible = TRUE; - sub_803547C(2, 1); - sub_803547C(1, 1); - sub_803547C(0, 1); + DigitObjUtil_HideOrShow(2, 1); + DigitObjUtil_HideOrShow(1, 1); + DigitObjUtil_HideOrShow(0, 1); } void sub_8022588(struct BerryCrushGame *r5) @@ -1855,9 +1855,9 @@ void sub_8022730(struct BerryCrushGame *r6) r6->unk138.unk78[r5]->invisible = FALSE; r6->unk138.unk78[r5]->animPaused = FALSE; } - sub_8034D14(0, 0, &gUnknown_082F4384[0]); - sub_8034D14(1, 0, &gUnknown_082F4384[1]); - sub_8034D14(2, 0, &gUnknown_082F4384[2]); + DigitObjUtil_CreatePrinter(0, 0, &gUnknown_082F4384[0]); + DigitObjUtil_CreatePrinter(1, 0, &gUnknown_082F4384[1]); + DigitObjUtil_CreatePrinter(2, 0, &gUnknown_082F4384[2]); if (r6->unk12 == 1) sub_8022554(&r6->unk138); } @@ -1875,9 +1875,9 @@ void sub_8022960(struct BerryCrushGame *r5) FreeSpritePaletteByTag(1); for (; r4 < ARRAY_COUNT(r5->unk138.unk78); ++r4) DestroySprite(r5->unk138.unk78[r4]); - sub_80353DC(2); - sub_80353DC(1); - sub_80353DC(0); + DigitObjUtil_DeletePrinter(2); + DigitObjUtil_DeletePrinter(1); + DigitObjUtil_DeletePrinter(0); for (r4 = 0; r4 < ARRAY_COUNT(r5->unk138.unk4C); ++r4) DestroySprite(r5->unk138.unk4C[r4]); for (r4 = 0; r4 < r5->unk9; ++r4) @@ -2317,10 +2317,10 @@ static u32 sub_80232EC(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r case 1: if (!IsLinkTaskFinished()) return 0; - sub_802EB24(0x1000, 0x1000, 120, 80, 0); + StartMinigameCountdown(0x1000, 0x1000, 120, 80, 0); break; case 2: - if (sub_802EB84()) + if (IsMinigameCountdownRunning()) return 0; // fallthrough case 0: diff --git a/src/credits.c b/src/credits.c index a8bed9a3f..dd1166d82 100644 --- a/src/credits.c +++ b/src/credits.c @@ -23,6 +23,7 @@ #include "constants/vars.h" #include "event_data.h" #include "random.h" +#include "constants/species.h" enum { diff --git a/src/data/pokemon_graphics/front_pic_anims.h b/src/data/pokemon_graphics/front_pic_anims.h index 4c97af1a7..671fc5fad 100644 --- a/src/data/pokemon_graphics/front_pic_anims.h +++ b/src/data/pokemon_graphics/front_pic_anims.h @@ -7391,3 +7391,6 @@ const union AnimCmd *const *const gMonFrontAnimsPtrTable[] = ANIM_CMD(UNOWN_EMARK), ANIM_CMD(UNOWN_QMARK), }; + +#undef ANIM_CMD +#undef ANIM_CMD_FULL diff --git a/src/data/pokemon_graphics/unknown_anims.h b/src/data/pokemon_graphics/unknown_anims.h index bb4862d09..ea7ab34a2 100644 --- a/src/data/pokemon_graphics/unknown_anims.h +++ b/src/data/pokemon_graphics/unknown_anims.h @@ -1,5 +1,5 @@ // unused and unkown -static const union AnimCmd gUnknown_082FF71C[] = +static const union AnimCmd sUnknownAnim_BLAZIKEN_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_FRAME(1, 25), @@ -9,7 +9,7 @@ static const union AnimCmd gUnknown_082FF71C[] = ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF734[] = +static const union AnimCmd sUnknownAnim_BLAZIKEN_2[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_FRAME(2, 8), @@ -17,20 +17,20 @@ static const union AnimCmd gUnknown_082FF734[] = ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF744[] = +static const union AnimCmd sUnknownAnim_BLAZIKEN_3[] = { ANIMCMD_FRAME(0, 10), ANIMCMD_FRAME(2, 10), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF750[] = +static const union AnimCmd sUnknownAnim_BLAZIKEN_4[] = { ANIMCMD_FRAME(0, 10), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF758[] = +static const union AnimCmd sUnknownAnim_MARSHTOMP_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_FRAME(1, 5), @@ -41,7 +41,7 @@ static const union AnimCmd gUnknown_082FF758[] = ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF774[] = +static const union AnimCmd sUnknownAnim_MARSHTOMP_2[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_FRAME(2, 12), @@ -52,14 +52,14 @@ static const union AnimCmd gUnknown_082FF774[] = ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF790[] = +static const union AnimCmd sUnknownAnim_MARSHTOMP_3[] = { ANIMCMD_FRAME(0, 14), ANIMCMD_FRAME(2, 12), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF79C[] = +static const union AnimCmd sUnknownAnim_POOCHYENA_1[] = { ANIMCMD_FRAME(0, 10), ANIMCMD_FRAME(1, 10), @@ -68,7 +68,7 @@ static const union AnimCmd gUnknown_082FF79C[] = ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF7B0[] = +static const union AnimCmd sUnknownAnim_POOCHYENA_2[] = { ANIMCMD_FRAME(0, 10), ANIMCMD_FRAME(2, 10), @@ -77,193 +77,193 @@ static const union AnimCmd gUnknown_082FF7B0[] = ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF7C4[] = +static const union AnimCmd sUnknownAnim_MIGHTYENA_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF7CC[] = +static const union AnimCmd sUnknownAnim_ZIGZAGOON_1[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF7D4[] = +static const union AnimCmd sUnknownAnim_LINOONE_1[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF7DC[] = +static const union AnimCmd sUnknownAnim_WURMPLE_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF7E4[] = +static const union AnimCmd sUnknownAnim_WURMPLE_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF7EC[] = +static const union AnimCmd sUnknownAnim_SILCOON_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF7F4[] = +static const union AnimCmd sUnknownAnim_SILCOON_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF7FC[] = +static const union AnimCmd sUnknownAnim_BEAUTIFLY_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF804[] = +static const union AnimCmd sUnknownAnim_BEAUTIFLY_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF80C[] = +static const union AnimCmd sUnknownAnim_CASCOON_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF814[] = +static const union AnimCmd sUnknownAnim_CASCOON_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF81C[] = +static const union AnimCmd sUnknownAnim_DUSTOX_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF824[] = +static const union AnimCmd sUnknownAnim_DUSTOX_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF82C[] = +static const union AnimCmd sUnknownAnim_LOMBRE_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF834[] = +static const union AnimCmd sUnknownAnim_LUDICOLO_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF83C[] = +static const union AnimCmd sUnknownAnim_LUDICOLO_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF844[] = +static const union AnimCmd sUnknownAnim_SEEDOT_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF84C[] = +static const union AnimCmd sUnknownAnim_NUZLEAF_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF854[] = +static const union AnimCmd sUnknownAnim_SHIFTRY_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF85C[] = +static const union AnimCmd sUnknownAnim_SHIFTRY_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF864[] = +static const union AnimCmd sUnknownAnim_TAILLOW_1[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF86C[] = +static const union AnimCmd sUnknownAnim_SWELLOW_1[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF874[] = +static const union AnimCmd sUnknownAnim_SHROOMISH_1[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF87C[] = +static const union AnimCmd sUnknownAnim_BRELOOM_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF884[] = +static const union AnimCmd sUnknownAnim_WINGULL_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF88C[] = +static const union AnimCmd sUnknownAnim_PELIPPER_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF894[] = +static const union AnimCmd sUnknownAnim_PELIPPER_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF89C[] = +static const union AnimCmd sUnknownAnim_SURSKIT_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF8A4[] = +static const union AnimCmd sUnknownAnim_SURSKIT_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF8AC[] = +static const union AnimCmd sUnknownAnim_MASQUERAIN_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF8B4[] = +static const union AnimCmd sUnknownAnim_MASQUERAIN_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF8BC[] = +static const union AnimCmd sUnknownAnim_WAILMER_1[] = { ANIMCMD_FRAME(0, 15), ANIMCMD_FRAME(8, 15), @@ -283,7 +283,7 @@ static const union AnimCmd gUnknown_082FF8BC[] = ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF8FC[] = +static const union AnimCmd sUnknownAnim_WAILMER_2[] = { ANIMCMD_FRAME(0, 10), ANIMCMD_FRAME(8, 15), @@ -295,7 +295,7 @@ static const union AnimCmd gUnknown_082FF8FC[] = ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF91C[] = +static const union AnimCmd sUnknownAnim_WAILMER_3[] = { ANIMCMD_FRAME(0, 10), ANIMCMD_FRAME(9, 10), @@ -304,26 +304,26 @@ static const union AnimCmd gUnknown_082FF91C[] = ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF930[] = +static const union AnimCmd sUnknownAnim_WAILMER_4[] = { ANIMCMD_FRAME(0, 15), ANIMCMD_FRAME(11, 15), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF93C[] = +static const union AnimCmd sUnknownAnim_SKITTY_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF944[] = +static const union AnimCmd sUnknownAnim_DELCATTY_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF94C[] = +static const union AnimCmd sUnknownAnim_KECLEON_1[] = { ANIMCMD_FRAME(0, 10), ANIMCMD_FRAME(1, 7), @@ -350,7 +350,7 @@ static const union AnimCmd gUnknown_082FF94C[] = ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FF9A8[] = +static const union AnimCmd sUnknownAnim_KECLEON_2[] = { ANIMCMD_FRAME(0, 12), ANIMCMD_FRAME(7, 12), @@ -376,7 +376,7 @@ static const union AnimCmd gUnknown_082FF9A8[] = ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFA00[] = +static const union AnimCmd sUnknownAnim_KECLEON_3[] = { ANIMCMD_FRAME(0, 12), ANIMCMD_FRAME(7, 12), @@ -402,182 +402,182 @@ static const union AnimCmd gUnknown_082FFA00[] = ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFA58[] = +static const union AnimCmd sUnknownAnim_KECLEON_4[] = { ANIMCMD_FRAME(0,18), ANIMCMD_FRAME(10, 18), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFA64[] = +static const union AnimCmd sUnknownAnim_BALTOY_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFA6C[] = +static const union AnimCmd sUnknownAnim_CLAYDOL_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFA74[] = +static const union AnimCmd sUnknownAnim_NOSEPASS_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFA7C[] = +static const union AnimCmd sUnknownAnim_SABLEYE_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFA84[] = +static const union AnimCmd sUnknownAnim_SABLEYE_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFA8C[] = +static const union AnimCmd sUnknownAnim_LUVDISC_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFA94[] = +static const union AnimCmd sUnknownAnim_LUVDISC_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFA9C[] = +static const union AnimCmd sUnknownAnim_FEEBAS_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFAA4[] = +static const union AnimCmd sUnknownAnim_FEEBAS_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFAAC[] = +static const union AnimCmd sUnknownAnim_MILOTIC_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFAB4[] = +static const union AnimCmd sUnknownAnim_MILOTIC_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFABC[] = +static const union AnimCmd sUnknownAnim_CARVANHA_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFAC4[] = +static const union AnimCmd sUnknownAnim_CARVANHA_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFACC[] = +static const union AnimCmd sUnknownAnim_SHARPEDO_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFAD4[] = +static const union AnimCmd sUnknownAnim_SHARPEDO_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFADC[] = +static const union AnimCmd sUnknownAnim_TRAPINCH_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFAE4[] = +static const union AnimCmd sUnknownAnim_VIBRAVA_1[] = { ANIMCMD_FRAME(0, 63), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFAEC[] = +static const union AnimCmd sUnknownAnim_FLYGON_1[] = { ANIMCMD_FRAME(0, 63), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFAF4[] = +static const union AnimCmd sUnknownAnim_MAKUHITA_1[] = { ANIMCMD_FRAME(0, 63), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFAFC[] = +static const union AnimCmd sUnknownAnim_HARIYAMA_1[] = { ANIMCMD_FRAME(0, 63), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFB04[] = +static const union AnimCmd sUnknownAnim_ELECTRIKE_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFB0C[] = +static const union AnimCmd sUnknownAnim_ELECTRIKE_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFB14[] = +static const union AnimCmd sUnknownAnim_MANECTRIC_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFB1C[] = +static const union AnimCmd sUnknownAnim_NUMEL_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFB24[] = +static const union AnimCmd sUnknownAnim_NUMEL_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFB2C[] = +static const union AnimCmd sUnknownAnim_CAMERUPT_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFB34[] = +static const union AnimCmd sUnknownAnim_SPHEAL_1[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFB3C[] = +static const union AnimCmd sUnknownAnim_SEALEO_1[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFB44[] = +static const union AnimCmd sUnknownAnim_WALREIN_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_FRAME(1, 18), @@ -588,7 +588,7 @@ static const union AnimCmd gUnknown_082FFB44[] = ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFB60[] = +static const union AnimCmd sUnknownAnim_WALREIN_2[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_FRAME(2, 18), @@ -599,7 +599,7 @@ static const union AnimCmd gUnknown_082FFB60[] = ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFB7C[] = +static const union AnimCmd sUnknownAnim_AZURILL_1[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_FRAME(2, 5), @@ -619,7 +619,7 @@ static const union AnimCmd gUnknown_082FFB7C[] = ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFBBC[] = +static const union AnimCmd sUnknownAnim_AZURILL_2[] = { ANIMCMD_FRAME(0, 6), ANIMCMD_FRAME(1, 6), @@ -632,7 +632,7 @@ static const union AnimCmd gUnknown_082FFBBC[] = ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFBE0[] = +static const union AnimCmd sUnknownAnim_AZURILL_3[] = { ANIMCMD_FRAME(0, 12), ANIMCMD_FRAME(5, 12), @@ -641,61 +641,61 @@ static const union AnimCmd gUnknown_082FFBE0[] = ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFBF4[] = +static const union AnimCmd sUnknownAnim_AZURILL_4[] = { ANIMCMD_FRAME(7, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFBFC[] = +static const union AnimCmd sUnknownAnim_SPOINK_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFC04[] = +static const union AnimCmd sUnknownAnim_SPOINK_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFC0C[] = +static const union AnimCmd sUnknownAnim_GRUMPIG_1[] = { ANIMCMD_FRAME(0, 63), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFC14[] = +static const union AnimCmd sUnknownAnim_PLUSLE_1[] = { ANIMCMD_FRAME(0, 63), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFC1C[] = +static const union AnimCmd sUnknownAnim_MINUN_1[] = { ANIMCMD_FRAME(0, 63), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFC24[] = +static const union AnimCmd sUnknownAnim_MAWILE_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFC2C[] = +static const union AnimCmd sUnknownAnim_MEDITITE_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFC34[] = +static const union AnimCmd sUnknownAnim_MEDICHAM_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFC3C[] = +static const union AnimCmd sUnknownAnim_SWABLU_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_FRAME(1, 10), @@ -706,7 +706,7 @@ static const union AnimCmd gUnknown_082FFC3C[] = ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFC58[] = +static const union AnimCmd sUnknownAnim_SWABLU_2[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_FRAME(2, 8), @@ -717,217 +717,217 @@ static const union AnimCmd gUnknown_082FFC58[] = ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFC74[] = +static const union AnimCmd sUnknownAnim_ALTARIA_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFC7C[] = +static const union AnimCmd sUnknownAnim_WYNAUT_1[] = { ANIMCMD_FRAME(0, 10), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFC84[] = +static const union AnimCmd sUnknownAnim_WYNAUT_2[] = { ANIMCMD_FRAME(1, 9), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFC8C[] = +static const union AnimCmd sUnknownAnim_DUSKULL_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFC94[] = +static const union AnimCmd sUnknownAnim_DUSKULL_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFC9C[] = +static const union AnimCmd sUnknownAnim_DUSCLOPS_1[] = { ANIMCMD_FRAME(0, 10), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFCA4[] = +static const union AnimCmd sUnknownAnim_DUSCLOPS_2[] = { ANIMCMD_FRAME(1, 10), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFCAC[] = +static const union AnimCmd sUnknownAnim_SLAKOTH_1[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFCB4[] = +static const union AnimCmd sUnknownAnim_VIGOROTH_1[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFCBC[] = +static const union AnimCmd sUnknownAnim_SLAKING_1[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFCC4[] = +static const union AnimCmd sUnknownAnim_GULPIN_1[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFCCC[] = +static const union AnimCmd sUnknownAnim_SWALOT_1[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFCD4[] = +static const union AnimCmd sUnknownAnim_TROPIUS_1[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFCDC[] = +static const union AnimCmd sUnknownAnim_CLAMPERL_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFCE4[] = +static const union AnimCmd sUnknownAnim_ABSOL_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFCEC[] = +static const union AnimCmd sUnknownAnim_SHUPPET_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFCF4[] = +static const union AnimCmd sUnknownAnim_SHUPPET_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFCFC[] = +static const union AnimCmd sUnknownAnim_BANETTE_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFD04[] = +static const union AnimCmd sUnknownAnim_ARON_1[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFD0C[] = +static const union AnimCmd sUnknownAnim_LAIRON_1[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFD14[] = +static const union AnimCmd sUnknownAnim_AGGRON_1[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFD1C[] = +static const union AnimCmd sUnknownAnim_CASTFORM_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFD24[] = +static const union AnimCmd sUnknownAnim_CASTFORM_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFD2C[] = +static const union AnimCmd sUnknownAnim_CASTFORM_3[] = { ANIMCMD_FRAME(2, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFD34[] = +static const union AnimCmd sUnknownAnim_CASTFORM_4[] = { ANIMCMD_FRAME(3, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFD3C[] = +static const union AnimCmd sUnknownAnim_VOLBEAT_1[] = { ANIMCMD_FRAME(0, 63), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFD44[] = +static const union AnimCmd sUnknownAnim_ILLUMISE_1[] = { ANIMCMD_FRAME(0, 63), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFD4C[] = +static const union AnimCmd sUnknownAnim_BAGON_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFD54[] = +static const union AnimCmd sUnknownAnim_BAGON_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFD5C[] = +static const union AnimCmd sUnknownAnim_SALAMENCE_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFD64[] = +static const union AnimCmd sUnknownAnim_SALAMENCE_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFD6C[] = +static const union AnimCmd sUnknownAnim_REGIROCK_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFD74[] = +static const union AnimCmd sUnknownAnim_REGICE_1[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFD7C[] = +static const union AnimCmd sUnknownAnim_REGISTEEL_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFD84[] = +static const union AnimCmd sUnknownAnim_REGISTEEL_2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFD8C[] = +static const union AnimCmd sUnknownAnim_RAYQUAZA_1[] = { ANIMCMD_FRAME(0, 20), ANIMCMD_FRAME(1, 30), @@ -936,7 +936,7 @@ static const union AnimCmd gUnknown_082FFD8C[] = ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFDA0[] = +static const union AnimCmd sUnknownAnim_RAYQUAZA_2[] = { ANIMCMD_FRAME(0, 20), ANIMCMD_FRAME(2, 20), @@ -945,1372 +945,1378 @@ static const union AnimCmd gUnknown_082FFDA0[] = ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFDB4[] = +static const union AnimCmd sUnknownAnim_Unused1[] = { ANIMCMD_FRAME(0, 10), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFDBC[] = +static const union AnimCmd sUnknownAnim_Unused2[] = { ANIMCMD_FRAME(0, 10), ANIMCMD_END, }; -static const union AnimCmd gUnknown_082FFDC4[] = +static const union AnimCmd sUnknownAnim_JIRACHI_1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const union AnimCmd *const gUnknown_082FFDCC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFDD0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFDD4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFDD8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFDDC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFDE0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFDE4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFDE8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFDEC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFDF0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFDF4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFDF8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFDFC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE00[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE04[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE08[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE0C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE10[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE14[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE18[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE1C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE20[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE24[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE28[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE2C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE30[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE34[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE38[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE3C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE40[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE44[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE48[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE4C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE50[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE54[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE58[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE5C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE60[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE64[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE68[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE6C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE70[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE74[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE78[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE7C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE80[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE84[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE88[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE8C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE90[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE94[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE98[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFE9C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFEA0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFEA4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFEA8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFEAC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFEB0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFEB4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFEB8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFEBC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFEC0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFEC4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFEC8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFECC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFED0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFED4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFED8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFEDC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFEE0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFEE4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFEE8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFEEC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFEF0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFEF4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFEF8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFEFC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF00[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF04[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF08[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF0C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF10[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF14[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF18[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF1C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF20[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF24[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF28[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF2C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF30[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF34[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF38[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF3C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF40[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF44[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF48[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF4C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF50[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF54[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF58[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF5C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF60[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF64[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF68[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF6C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF70[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF74[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF78[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF7C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF80[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF84[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF88[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF8C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF90[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF94[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF98[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFF9C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFA0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFA4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFA8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFAC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFB0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFB4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFB8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFBC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFC0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFC4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFC8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFCC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFD0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFD4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFD8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFDC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFE0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFE4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFE8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFEC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFF0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFF4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFF8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_082FFFFC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300000[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300004[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300008[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830000C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300010[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300014[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300018[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830001C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300020[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300024[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300028[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830002C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300030[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300034[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300038[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830003C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300040[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300044[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300048[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830004C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300050[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300054[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300058[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830005C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300060[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300064[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300068[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830006C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300070[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300074[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300078[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830007C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300080[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300084[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300088[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830008C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300090[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300094[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300098[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830009C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000A0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000A4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000A8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000AC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000B0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000B4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000B8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000BC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000C0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000C4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000C8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000CC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000D0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000D4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000D8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000DC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000E0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000E4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000E8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000EC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000F0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000F4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000F8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083000FC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300100[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300104[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300108[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830010C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300110[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300114[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300118[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830011C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300120[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300124[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300128[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830012C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300130[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300134[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300138[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830013C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300140[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300144[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300148[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830014C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300150[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300154[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300158[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830015C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300160[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300164[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300168[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830016C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300170[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300174[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300178[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830017C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300180[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300184[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300188[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830018C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300190[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300194[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300198[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830019C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083001A0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083001A4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083001A8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083001AC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083001B0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083001B4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083001B8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083001BC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083001C0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083001C4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083001C8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083001CC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083001D0[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_NONE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_BULBASAUR[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_IVYSAUR[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_VENUSAUR[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CHARMANDER[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CHARMELEON[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CHARIZARD[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SQUIRTLE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_WARTORTLE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_BLASTOISE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CATERPIE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_METAPOD[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_BUTTERFREE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_WEEDLE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_KAKUNA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_BEEDRILL[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_PIDGEY[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_PIDGEOTTO[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_PIDGEOT[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_RATTATA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_RATICATE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SPEAROW[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_FEAROW[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_EKANS[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_ARBOK[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_PIKACHU[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_RAICHU[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SANDSHREW[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SANDSLASH[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_NIDORAN_F[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_NIDORINA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_NIDOQUEEN[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_NIDORAN_M[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_NIDORINO[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_NIDOKING[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CLEFAIRY[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CLEFABLE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_VULPIX[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_NINETALES[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_JIGGLYPUFF[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_WIGGLYTUFF[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_ZUBAT[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_GOLBAT[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_ODDISH[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_GLOOM[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_VILEPLUME[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_PARAS[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_PARASECT[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_VENONAT[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_VENOMOTH[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_DIGLETT[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_DUGTRIO[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MEOWTH[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_PERSIAN[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_PSYDUCK[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_GOLDUCK[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MANKEY[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_PRIMEAPE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_GROWLITHE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_ARCANINE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_POLIWAG[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_POLIWHIRL[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_POLIWRATH[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_ABRA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_KADABRA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_ALAKAZAM[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MACHOP[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MACHOKE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MACHAMP[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_BELLSPROUT[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_WEEPINBELL[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_VICTREEBEL[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_TENTACOOL[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_TENTACRUEL[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_GEODUDE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_GRAVELER[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_GOLEM[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_PONYTA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_RAPIDASH[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SLOWPOKE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SLOWBRO[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MAGNEMITE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MAGNETON[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_FARFETCHD[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_DODUO[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_DODRIO[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SEEL[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_DEWGONG[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_GRIMER[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MUK[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SHELLDER[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CLOYSTER[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_GASTLY[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_HAUNTER[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_GENGAR[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_ONIX[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_DROWZEE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_HYPNO[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_KRABBY[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_KINGLER[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_VOLTORB[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_ELECTRODE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_EXEGGCUTE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_EXEGGUTOR[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CUBONE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MAROWAK[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_HITMONLEE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_HITMONCHAN[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_LICKITUNG[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_KOFFING[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_WEEZING[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_RHYHORN[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_RHYDON[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CHANSEY[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_TANGELA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_KANGASKHAN[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_HORSEA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SEADRA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_GOLDEEN[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SEAKING[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_STARYU[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_STARMIE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MR_MIME[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SCYTHER[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_JYNX[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_ELECTABUZZ[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MAGMAR[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_PINSIR[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_TAUROS[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MAGIKARP[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_GYARADOS[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_LAPRAS[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_DITTO[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_EEVEE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_VAPOREON[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_JOLTEON[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_FLAREON[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_PORYGON[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_OMANYTE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_OMASTAR[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_KABUTO[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_KABUTOPS[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_AERODACTYL[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SNORLAX[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_ARTICUNO[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_ZAPDOS[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MOLTRES[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_DRATINI[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_DRAGONAIR[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_DRAGONITE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MEWTWO[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MEW[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CHIKORITA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_BAYLEEF[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MEGANIUM[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CYNDAQUIL[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_QUILAVA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_TYPHLOSION[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_TOTODILE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CROCONAW[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_FERALIGATR[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SENTRET[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_FURRET[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_HOOTHOOT[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_NOCTOWL[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_LEDYBA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_LEDIAN[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SPINARAK[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_ARIADOS[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CROBAT[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CHINCHOU[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_LANTURN[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_PICHU[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CLEFFA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_IGGLYBUFF[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_TOGEPI[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_TOGETIC[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_NATU[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_XATU[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MAREEP[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_FLAAFFY[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_AMPHAROS[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_BELLOSSOM[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MARILL[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_AZUMARILL[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SUDOWOODO[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_POLITOED[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_HOPPIP[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SKIPLOOM[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_JUMPLUFF[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_AIPOM[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SUNKERN[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SUNFLORA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_YANMA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_WOOPER[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_QUAGSIRE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_ESPEON[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UMBREON[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MURKROW[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SLOWKING[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MISDREAVUS[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_WOBBUFFET[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_GIRAFARIG[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_PINECO[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_FORRETRESS[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_DUNSPARCE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_GLIGAR[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_STEELIX[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SNUBBULL[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_GRANBULL[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_QWILFISH[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SCIZOR[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SHUCKLE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_HERACROSS[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SNEASEL[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_TEDDIURSA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_URSARING[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SLUGMA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MAGCARGO[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SWINUB[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_PILOSWINE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CORSOLA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_REMORAID[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_OCTILLERY[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_DELIBIRD[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MANTINE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SKARMORY[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_HOUNDOUR[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_HOUNDOOM[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_KINGDRA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_PHANPY[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_DONPHAN[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_PORYGON2[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_STANTLER[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SMEARGLE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_TYROGUE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_HITMONTOP[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SMOOCHUM[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_ELEKID[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MAGBY[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MILTANK[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_BLISSEY[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_RAIKOU[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_ENTEI[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SUICUNE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_LARVITAR[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_PUPITAR[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_TYRANITAR[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_LUGIA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_HO_OH[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CELEBI[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_OLD_UNOWN[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_TREECKO[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_GROVYLE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SCEPTILE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_TORCHIC[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_COMBUSKEN[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083001D4[] = +static const union AnimCmd *const sUnknownAnims_BLAZIKEN[] = { sAnim_GeneralFrame0, - gUnknown_082FF71C, - gUnknown_082FF734, - gUnknown_082FF744, - gUnknown_082FF750, + sUnknownAnim_BLAZIKEN_1, + sUnknownAnim_BLAZIKEN_2, + sUnknownAnim_BLAZIKEN_3, + sUnknownAnim_BLAZIKEN_4, }; -static const union AnimCmd *const gUnknown_083001E8[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_MUDKIP[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083001EC[] = +static const union AnimCmd *const sUnknownAnims_MARSHTOMP[] = { sAnim_GeneralFrame0, - gUnknown_082FF758, - gUnknown_082FF774, - gUnknown_082FF790, + sUnknownAnim_MARSHTOMP_1, + sUnknownAnim_MARSHTOMP_2, + sUnknownAnim_MARSHTOMP_3, }; -static const union AnimCmd *const gUnknown_083001FC[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SWAMPERT[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300200[] = +static const union AnimCmd *const sUnknownAnims_POOCHYENA[] = { sAnim_GeneralFrame0, - gUnknown_082FF79C, - gUnknown_082FF7B0, + sUnknownAnim_POOCHYENA_1, + sUnknownAnim_POOCHYENA_2, }; -static const union AnimCmd *const gUnknown_0830020C[] = +static const union AnimCmd *const sUnknownAnims_MIGHTYENA[] = { sAnim_GeneralFrame0, - gUnknown_082FF7C4, + sUnknownAnim_MIGHTYENA_1, }; -static const union AnimCmd *const gUnknown_08300214[] = +static const union AnimCmd *const sUnknownAnims_ZIGZAGOON[] = { sAnim_GeneralFrame0, - gUnknown_082FF7CC, + sUnknownAnim_ZIGZAGOON_1, }; -static const union AnimCmd *const gUnknown_0830021C[] = +static const union AnimCmd *const sUnknownAnims_LINOONE[] = { sAnim_GeneralFrame0, - gUnknown_082FF7D4, + sUnknownAnim_LINOONE_1, }; -static const union AnimCmd *const gUnknown_08300224[] = +static const union AnimCmd *const sUnknownAnims_WURMPLE[] = { sAnim_GeneralFrame0, - gUnknown_082FF7DC, - gUnknown_082FF7E4, + sUnknownAnim_WURMPLE_1, + sUnknownAnim_WURMPLE_2, }; -static const union AnimCmd *const gUnknown_08300230[] = +static const union AnimCmd *const sUnknownAnims_SILCOON[] = { sAnim_GeneralFrame0, - gUnknown_082FF7EC, - gUnknown_082FF7F4, + sUnknownAnim_SILCOON_1, + sUnknownAnim_SILCOON_2, }; -static const union AnimCmd *const gUnknown_0830023C[] = +static const union AnimCmd *const sUnknownAnims_BEAUTIFLY[] = { sAnim_GeneralFrame0, - gUnknown_082FF7FC, - gUnknown_082FF804, + sUnknownAnim_BEAUTIFLY_1, + sUnknownAnim_BEAUTIFLY_2, }; -static const union AnimCmd *const gUnknown_08300248[] = +static const union AnimCmd *const sUnknownAnims_CASCOON[] = { sAnim_GeneralFrame0, - gUnknown_082FF80C, - gUnknown_082FF814, + sUnknownAnim_CASCOON_1, + sUnknownAnim_CASCOON_2, }; -static const union AnimCmd *const gUnknown_08300254[] = +static const union AnimCmd *const sUnknownAnims_DUSTOX[] = { sAnim_GeneralFrame0, - gUnknown_082FF81C, - gUnknown_082FF824, + sUnknownAnim_DUSTOX_1, + sUnknownAnim_DUSTOX_2, }; -static const union AnimCmd *const gUnknown_08300260[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_LOTAD[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300264[] = +static const union AnimCmd *const sUnknownAnims_LOMBRE[] = { sAnim_GeneralFrame0, - gUnknown_082FF82C, + sUnknownAnim_LOMBRE_1, }; -static const union AnimCmd *const gUnknown_0830026C[] = +static const union AnimCmd *const sUnknownAnims_LUDICOLO[] = { sAnim_GeneralFrame0, - gUnknown_082FF834, - gUnknown_082FF83C, + sUnknownAnim_LUDICOLO_1, + sUnknownAnim_LUDICOLO_2, }; -static const union AnimCmd *const gUnknown_08300278[] = +static const union AnimCmd *const sUnknownAnims_SEEDOT[] = { sAnim_GeneralFrame0, - gUnknown_082FF844, + sUnknownAnim_SEEDOT_1, }; -static const union AnimCmd *const gUnknown_08300280[] = +static const union AnimCmd *const sUnknownAnims_NUZLEAF[] = { sAnim_GeneralFrame0, - gUnknown_082FF84C, + sUnknownAnim_NUZLEAF_1, }; -static const union AnimCmd *const gUnknown_08300288[] = +static const union AnimCmd *const sUnknownAnims_SHIFTRY[] = { sAnim_GeneralFrame0, - gUnknown_082FF854, - gUnknown_082FF85C, + sUnknownAnim_SHIFTRY_1, + sUnknownAnim_SHIFTRY_2, }; -static const union AnimCmd *const gUnknown_08300294[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300298[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830029C[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_NINCADA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_NINJASK[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SHEDINJA[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083002A0[] = +static const union AnimCmd *const sUnknownAnims_TAILLOW[] = { sAnim_GeneralFrame0, - gUnknown_082FF864, + sUnknownAnim_TAILLOW_1, }; -static const union AnimCmd *const gUnknown_083002A8[] = +static const union AnimCmd *const sUnknownAnims_SWELLOW[] = { sAnim_GeneralFrame0, - gUnknown_082FF86C, + sUnknownAnim_SWELLOW_1, }; -static const union AnimCmd *const gUnknown_083002B0[] = +static const union AnimCmd *const sUnknownAnims_SHROOMISH[] = { sAnim_GeneralFrame0, - gUnknown_082FF874, + sUnknownAnim_SHROOMISH_1, }; -static const union AnimCmd *const gUnknown_083002B8[] = +static const union AnimCmd *const sUnknownAnims_BRELOOM[] = { sAnim_GeneralFrame0, - gUnknown_082FF87C, + sUnknownAnim_BRELOOM_1, }; -static const union AnimCmd *const gUnknown_083002C0[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SPINDA[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083002C4[] = +static const union AnimCmd *const sUnknownAnims_WINGULL[] = { sAnim_GeneralFrame0, - gUnknown_082FF884, + sUnknownAnim_WINGULL_1, }; -static const union AnimCmd *const gUnknown_083002CC[] = +static const union AnimCmd *const sUnknownAnims_PELIPPER[] = { sAnim_GeneralFrame0, - gUnknown_082FF88C, - gUnknown_082FF894, + sUnknownAnim_PELIPPER_1, + sUnknownAnim_PELIPPER_2, }; -static const union AnimCmd *const gUnknown_083002D8[] = +static const union AnimCmd *const sUnknownAnims_SURSKIT[] = { sAnim_GeneralFrame0, - gUnknown_082FF89C, - gUnknown_082FF8A4, + sUnknownAnim_SURSKIT_1, + sUnknownAnim_SURSKIT_2, }; -static const union AnimCmd *const gUnknown_083002E4[] = +static const union AnimCmd *const sUnknownAnims_MASQUERAIN[] = { sAnim_GeneralFrame0, - gUnknown_082FF8AC, - gUnknown_082FF8B4, + sUnknownAnim_MASQUERAIN_1, + sUnknownAnim_MASQUERAIN_2, }; -static const union AnimCmd *const gUnknown_083002F0[] = +static const union AnimCmd *const sUnknownAnims_WAILMER[] = { sAnim_GeneralFrame0, - gUnknown_082FF8BC, - gUnknown_082FF8FC, - gUnknown_082FF91C, - gUnknown_082FF930, + sUnknownAnim_WAILMER_1, + sUnknownAnim_WAILMER_2, + sUnknownAnim_WAILMER_3, + sUnknownAnim_WAILMER_4, }; -static const union AnimCmd *const gUnknown_08300304[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_WAILORD[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300308[] = +static const union AnimCmd *const sUnknownAnims_SKITTY[] = { sAnim_GeneralFrame0, - gUnknown_082FF93C, + sUnknownAnim_SKITTY_1, }; -static const union AnimCmd *const gUnknown_08300310[] = +static const union AnimCmd *const sUnknownAnims_DELCATTY[] = { sAnim_GeneralFrame0, - gUnknown_082FF944, + sUnknownAnim_DELCATTY_1, }; -static const union AnimCmd *const gUnknown_08300318[] = +static const union AnimCmd *const sUnknownAnims_KECLEON[] = { sAnim_GeneralFrame0, - gUnknown_082FF94C, - gUnknown_082FF9A8, - gUnknown_082FFA00, - gUnknown_082FFA58, + sUnknownAnim_KECLEON_1, + sUnknownAnim_KECLEON_2, + sUnknownAnim_KECLEON_3, + sUnknownAnim_KECLEON_4, }; -static const union AnimCmd *const gUnknown_0830032C[] = +static const union AnimCmd *const sUnknownAnims_BALTOY[] = { sAnim_GeneralFrame0, - gUnknown_082FFA64, + sUnknownAnim_BALTOY_1, }; -static const union AnimCmd *const gUnknown_08300334[] = +static const union AnimCmd *const sUnknownAnims_CLAYDOL[] = { sAnim_GeneralFrame0, - gUnknown_082FFA6C, + sUnknownAnim_CLAYDOL_1, }; -static const union AnimCmd *const gUnknown_0830033C[] = +static const union AnimCmd *const sUnknownAnims_NOSEPASS[] = { sAnim_GeneralFrame0, - gUnknown_082FFA74, + sUnknownAnim_NOSEPASS_1, }; -static const union AnimCmd *const gUnknown_08300344[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_TORKOAL[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300348[] = +static const union AnimCmd *const sUnknownAnims_SABLEYE[] = { sAnim_GeneralFrame0, - gUnknown_082FFA7C, - gUnknown_082FFA84, + sUnknownAnim_SABLEYE_1, + sUnknownAnim_SABLEYE_2, }; -static const union AnimCmd *const gUnknown_08300354[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300358[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_BARBOACH[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_WHISCASH[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830035C[] = +static const union AnimCmd *const sUnknownAnims_LUVDISC[] = { sAnim_GeneralFrame0, - gUnknown_082FFA8C, - gUnknown_082FFA94, + sUnknownAnim_LUVDISC_1, + sUnknownAnim_LUVDISC_2, }; -static const union AnimCmd *const gUnknown_08300368[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830036C[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CORPHISH[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CRAWDAUNT[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300370[] = +static const union AnimCmd *const sUnknownAnims_FEEBAS[] = { sAnim_GeneralFrame0, - gUnknown_082FFA9C, - gUnknown_082FFAA4, + sUnknownAnim_FEEBAS_1, + sUnknownAnim_FEEBAS_2, }; -static const union AnimCmd *const gUnknown_0830037C[] = +static const union AnimCmd *const sUnknownAnims_MILOTIC[] = { sAnim_GeneralFrame0, - gUnknown_082FFAAC, - gUnknown_082FFAB4, + sUnknownAnim_MILOTIC_1, + sUnknownAnim_MILOTIC_2, }; -static const union AnimCmd *const gUnknown_08300388[] = +static const union AnimCmd *const sUnknownAnims_CARVANHA[] = { sAnim_GeneralFrame0, - gUnknown_082FFABC, - gUnknown_082FFAC4, + sUnknownAnim_CARVANHA_1, + sUnknownAnim_CARVANHA_2, }; -static const union AnimCmd *const gUnknown_08300394[] = +static const union AnimCmd *const sUnknownAnims_SHARPEDO[] = { sAnim_GeneralFrame0, - gUnknown_082FFACC, - gUnknown_082FFAD4, + sUnknownAnim_SHARPEDO_1, + sUnknownAnim_SHARPEDO_2, }; -static const union AnimCmd *const gUnknown_083003A0[] = +static const union AnimCmd *const sUnknownAnims_TRAPINCH[] = { sAnim_GeneralFrame0, - gUnknown_082FFADC, + sUnknownAnim_TRAPINCH_1, }; -static const union AnimCmd *const gUnknown_083003A8[] = +static const union AnimCmd *const sUnknownAnims_VIBRAVA[] = { sAnim_GeneralFrame0, - gUnknown_082FFAE4, + sUnknownAnim_VIBRAVA_1, }; -static const union AnimCmd *const gUnknown_083003B0[] = +static const union AnimCmd *const sUnknownAnims_FLYGON[] = { sAnim_GeneralFrame0, - gUnknown_082FFAEC, + sUnknownAnim_FLYGON_1, }; -static const union AnimCmd *const gUnknown_083003B8[] = +static const union AnimCmd *const sUnknownAnims_MAKUHITA[] = { sAnim_GeneralFrame0, - gUnknown_082FFAF4, + sUnknownAnim_MAKUHITA_1, }; -static const union AnimCmd *const gUnknown_083003C0[] = +static const union AnimCmd *const sUnknownAnims_HARIYAMA[] = { sAnim_GeneralFrame0, - gUnknown_082FFAFC, + sUnknownAnim_HARIYAMA_1, }; -static const union AnimCmd *const gUnknown_083003C8[] = +static const union AnimCmd *const sUnknownAnims_ELECTRIKE[] = { sAnim_GeneralFrame0, - gUnknown_082FFB04, - gUnknown_082FFB0C, + sUnknownAnim_ELECTRIKE_1, + sUnknownAnim_ELECTRIKE_2, }; -static const union AnimCmd *const gUnknown_083003D4[] = +static const union AnimCmd *const sUnknownAnims_MANECTRIC[] = { sAnim_GeneralFrame0, - gUnknown_082FFB14, + sUnknownAnim_MANECTRIC_1, }; -static const union AnimCmd *const gUnknown_083003DC[] = +static const union AnimCmd *const sUnknownAnims_NUMEL[] = { sAnim_GeneralFrame0, - gUnknown_082FFB1C, - gUnknown_082FFB24, + sUnknownAnim_NUMEL_1, + sUnknownAnim_NUMEL_2, }; -static const union AnimCmd *const gUnknown_083003E8[] = +static const union AnimCmd *const sUnknownAnims_CAMERUPT[] = { sAnim_GeneralFrame0, - gUnknown_082FFB2C, + sUnknownAnim_CAMERUPT_1, }; -static const union AnimCmd *const gUnknown_083003F0[] = +static const union AnimCmd *const sUnknownAnims_SPHEAL[] = { sAnim_GeneralFrame0, - gUnknown_082FFB34, + sUnknownAnim_SPHEAL_1, }; -static const union AnimCmd *const gUnknown_083003F8[] = +static const union AnimCmd *const sUnknownAnims_SEALEO[] = { sAnim_GeneralFrame0, - gUnknown_082FFB3C, + sUnknownAnim_SEALEO_1, }; -static const union AnimCmd *const gUnknown_08300400[] = +static const union AnimCmd *const sUnknownAnims_WALREIN[] = { sAnim_GeneralFrame0, - gUnknown_082FFB44, - gUnknown_082FFB60, + sUnknownAnim_WALREIN_1, + sUnknownAnim_WALREIN_2, }; -static const union AnimCmd *const gUnknown_0830040C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300410[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300414[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300418[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830041C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300420[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CACNEA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CACTURNE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SNORUNT[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_GLALIE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_LUNATONE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SOLROCK[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300424[] = +static const union AnimCmd *const sUnknownAnims_AZURILL[] = { sAnim_GeneralFrame0, - gUnknown_082FFB7C, - gUnknown_082FFBBC, - gUnknown_082FFBE0, - gUnknown_082FFBF4, + sUnknownAnim_AZURILL_1, + sUnknownAnim_AZURILL_2, + sUnknownAnim_AZURILL_3, + sUnknownAnim_AZURILL_4, }; -static const union AnimCmd *const gUnknown_08300438[] = +static const union AnimCmd *const sUnknownAnims_SPOINK[] = { sAnim_GeneralFrame0, - gUnknown_082FFBFC, - gUnknown_082FFC04, + sUnknownAnim_SPOINK_1, + sUnknownAnim_SPOINK_2, }; -static const union AnimCmd *const gUnknown_08300444[] = +static const union AnimCmd *const sUnknownAnims_GRUMPIG[] = { sAnim_GeneralFrame0, - gUnknown_082FFC0C, + sUnknownAnim_GRUMPIG_1, }; -static const union AnimCmd *const gUnknown_0830044C[] = +static const union AnimCmd *const sUnknownAnims_PLUSLE[] = { sAnim_GeneralFrame0, - gUnknown_082FFC14, + sUnknownAnim_PLUSLE_1, }; -static const union AnimCmd *const gUnknown_08300454[] = +static const union AnimCmd *const sUnknownAnims_MINUN[] = { sAnim_GeneralFrame0, - gUnknown_082FFC1C, + sUnknownAnim_MINUN_1, }; -static const union AnimCmd *const gUnknown_0830045C[] = +static const union AnimCmd *const sUnknownAnims_MAWILE[] = { sAnim_GeneralFrame0, - gUnknown_082FFC24, + sUnknownAnim_MAWILE_1, }; -static const union AnimCmd *const gUnknown_08300464[] = +static const union AnimCmd *const sUnknownAnims_MEDITITE[] = { sAnim_GeneralFrame0, - gUnknown_082FFC2C, + sUnknownAnim_MEDITITE_1, }; -static const union AnimCmd *const gUnknown_0830046C[] = +static const union AnimCmd *const sUnknownAnims_MEDICHAM[] = { sAnim_GeneralFrame0, - gUnknown_082FFC34, + sUnknownAnim_MEDICHAM_1, }; -static const union AnimCmd *const gUnknown_08300474[] = +static const union AnimCmd *const sUnknownAnims_SWABLU[] = { sAnim_GeneralFrame0, - gUnknown_082FFC3C, - gUnknown_082FFC58, + sUnknownAnim_SWABLU_1, + sUnknownAnim_SWABLU_2, }; -static const union AnimCmd *const gUnknown_08300480[] = +static const union AnimCmd *const sUnknownAnims_ALTARIA[] = { sAnim_GeneralFrame0, - gUnknown_082FFC74, + sUnknownAnim_ALTARIA_1, }; -static const union AnimCmd *const gUnknown_08300488[] = +static const union AnimCmd *const sUnknownAnims_WYNAUT[] = { sAnim_GeneralFrame0, - gUnknown_082FFC7C, - gUnknown_082FFC84, + sUnknownAnim_WYNAUT_1, + sUnknownAnim_WYNAUT_2, }; -static const union AnimCmd *const gUnknown_08300494[] = +static const union AnimCmd *const sUnknownAnims_DUSKULL[] = { sAnim_GeneralFrame0, - gUnknown_082FFC8C, - gUnknown_082FFC94, + sUnknownAnim_DUSKULL_1, + sUnknownAnim_DUSKULL_2, }; -static const union AnimCmd *const gUnknown_083004A0[] = +static const union AnimCmd *const sUnknownAnims_DUSCLOPS[] = { sAnim_GeneralFrame0, - gUnknown_082FFC9C, - gUnknown_082FFCA4, + sUnknownAnim_DUSCLOPS_1, + sUnknownAnim_DUSCLOPS_2, }; -static const union AnimCmd *const gUnknown_083004AC[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_ROSELIA[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083004B0[] = +static const union AnimCmd *const sUnknownAnims_SLAKOTH[] = { sAnim_GeneralFrame0, - gUnknown_082FFCAC, + sUnknownAnim_SLAKOTH_1, }; -static const union AnimCmd *const gUnknown_083004B8[] = +static const union AnimCmd *const sUnknownAnims_VIGOROTH[] = { sAnim_GeneralFrame0, - gUnknown_082FFCB4, + sUnknownAnim_VIGOROTH_1, }; -static const union AnimCmd *const gUnknown_083004C0[] = +static const union AnimCmd *const sUnknownAnims_SLAKING[] = { sAnim_GeneralFrame0, - gUnknown_082FFCBC, + sUnknownAnim_SLAKING_1, }; -static const union AnimCmd *const gUnknown_083004C8[] = +static const union AnimCmd *const sUnknownAnims_GULPIN[] = { sAnim_GeneralFrame0, - gUnknown_082FFCC4, + sUnknownAnim_GULPIN_1, }; -static const union AnimCmd *const gUnknown_083004D0[] = +static const union AnimCmd *const sUnknownAnims_SWALOT[] = { sAnim_GeneralFrame0, - gUnknown_082FFCCC, + sUnknownAnim_SWALOT_1, }; -static const union AnimCmd *const gUnknown_083004D8[] = +static const union AnimCmd *const sUnknownAnims_TROPIUS[] = { sAnim_GeneralFrame0, - gUnknown_082FFCD4, + sUnknownAnim_TROPIUS_1, }; -static const union AnimCmd *const gUnknown_083004E0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083004E4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083004E8[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_WHISMUR[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_LOUDRED[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_EXPLOUD[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083004EC[] = +static const union AnimCmd *const sUnknownAnims_CLAMPERL[] = { sAnim_GeneralFrame0, - gUnknown_082FFCDC, + sUnknownAnim_CLAMPERL_1, }; -static const union AnimCmd *const gUnknown_083004F4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083004F8[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_HUNTAIL[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_GOREBYSS[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083004FC[] = +static const union AnimCmd *const sUnknownAnims_ABSOL[] = { sAnim_GeneralFrame0, - gUnknown_082FFCE4, + sUnknownAnim_ABSOL_1, }; -static const union AnimCmd *const gUnknown_08300504[] = +static const union AnimCmd *const sUnknownAnims_SHUPPET[] = { sAnim_GeneralFrame0, - gUnknown_082FFCEC, - gUnknown_082FFCF4, + sUnknownAnim_SHUPPET_1, + sUnknownAnim_SHUPPET_2, }; -static const union AnimCmd *const gUnknown_08300510[] = +static const union AnimCmd *const sUnknownAnims_BANETTE[] = { sAnim_GeneralFrame0, - gUnknown_082FFCFC, + sUnknownAnim_BANETTE_1, }; -static const union AnimCmd *const gUnknown_08300518[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830051C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300520[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SEVIPER[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_ZANGOOSE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_RELICANTH[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300524[] = +static const union AnimCmd *const sUnknownAnims_ARON[] = { sAnim_GeneralFrame0, - gUnknown_082FFD04, + sUnknownAnim_ARON_1, }; -static const union AnimCmd *const gUnknown_0830052C[] = +static const union AnimCmd *const sUnknownAnims_LAIRON[] = { sAnim_GeneralFrame0, - gUnknown_082FFD0C, + sUnknownAnim_LAIRON_1, }; -static const union AnimCmd *const gUnknown_08300534[] = +static const union AnimCmd *const sUnknownAnims_AGGRON[] = { sAnim_GeneralFrame0, - gUnknown_082FFD14, + sUnknownAnim_AGGRON_1, }; -static const union AnimCmd *const gUnknown_0830053C[] = +static const union AnimCmd *const sUnknownAnims_CASTFORM[] = { sAnim_GeneralFrame0, - gUnknown_082FFD1C, - gUnknown_082FFD24, - gUnknown_082FFD2C, - gUnknown_082FFD34, + sUnknownAnim_CASTFORM_1, + sUnknownAnim_CASTFORM_2, + sUnknownAnim_CASTFORM_3, + sUnknownAnim_CASTFORM_4, }; -static const union AnimCmd *const gUnknown_08300550[] = +static const union AnimCmd *const sUnknownAnims_VOLBEAT[] = { sAnim_GeneralFrame0, - gUnknown_082FFD3C, + sUnknownAnim_VOLBEAT_1, }; -static const union AnimCmd *const gUnknown_08300558[] = +static const union AnimCmd *const sUnknownAnims_ILLUMISE[] = { sAnim_GeneralFrame0, - gUnknown_082FFD44, + sUnknownAnim_ILLUMISE_1, }; -static const union AnimCmd *const gUnknown_08300560[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300564[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300568[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830056C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300570[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300574[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300578[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_LILEEP[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CRADILY[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_ANORITH[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_ARMALDO[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_RALTS[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_KIRLIA[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_GARDEVOIR[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830057C[] = +static const union AnimCmd *const sUnknownAnims_BAGON[] = { sAnim_GeneralFrame0, - gUnknown_082FFD4C, - gUnknown_082FFD54, + sUnknownAnim_BAGON_1, + sUnknownAnim_BAGON_2, }; -static const union AnimCmd *const gUnknown_08300588[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_SHELGON[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830058C[] = +static const union AnimCmd *const sUnknownAnims_SALAMENCE[] = { sAnim_GeneralFrame0, - gUnknown_082FFD5C, - gUnknown_082FFD64, + sUnknownAnim_SALAMENCE_1, + sUnknownAnim_SALAMENCE_2, }; -static const union AnimCmd *const gUnknown_08300598[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830059C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083005A0[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_BELDUM[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_METANG[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_METAGROSS[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083005A4[] = +static const union AnimCmd *const sUnknownAnims_REGIROCK[] = { sAnim_GeneralFrame0, - gUnknown_082FFD6C, + sUnknownAnim_REGIROCK_1, }; -static const union AnimCmd *const gUnknown_083005AC[] = +static const union AnimCmd *const sUnknownAnims_REGICE[] = { sAnim_GeneralFrame0, - gUnknown_082FFD74, + sUnknownAnim_REGICE_1, }; -static const union AnimCmd *const gUnknown_083005B4[] = +static const union AnimCmd *const sUnknownAnims_REGISTEEL[] = { sAnim_GeneralFrame0, - gUnknown_082FFD7C, - gUnknown_082FFD84, + sUnknownAnim_REGISTEEL_1, + sUnknownAnim_REGISTEEL_2, }; -static const union AnimCmd *const gUnknown_083005C0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083005C4[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_KYOGRE[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_GROUDON[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083005C8[] = +static const union AnimCmd *const sUnknownAnims_RAYQUAZA[] = { sAnim_GeneralFrame0, - gUnknown_082FFD8C, - gUnknown_082FFDA0, + sUnknownAnim_RAYQUAZA_1, + sUnknownAnim_RAYQUAZA_2, }; -static const union AnimCmd *const gUnknown_083005D4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083005D8[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_LATIAS[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_LATIOS[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083005DC[] = +static const union AnimCmd *const sUnknownAnims_JIRACHI[] = { sAnim_GeneralFrame0, - gUnknown_082FFDC4, + sUnknownAnim_JIRACHI_1, }; -static const union AnimCmd *const gUnknown_083005E4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083005E8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083005EC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083005F0[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083005F4[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083005F8[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_083005FC[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300600[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300604[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300608[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830060C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300610[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300614[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300618[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830061C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300620[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300624[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300628[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830062C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300630[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300634[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300638[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830063C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300640[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300644[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300648[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_0830064C[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300650[] = {sAnim_GeneralFrame0}; -static const union AnimCmd *const gUnknown_08300654[] = {sAnim_GeneralFrame0}; - -const union AnimCmd *const *const gUnknownAnimsTable[] = -{ - gUnknown_082FFDCC, - gUnknown_082FFDD0, - gUnknown_082FFDD4, - gUnknown_082FFDD8, - gUnknown_082FFDDC, - gUnknown_082FFDE0, - gUnknown_082FFDE4, - gUnknown_082FFDE8, - gUnknown_082FFDEC, - gUnknown_082FFDF0, - gUnknown_082FFDF4, - gUnknown_082FFDF8, - gUnknown_082FFDFC, - gUnknown_082FFE00, - gUnknown_082FFE04, - gUnknown_082FFE08, - gUnknown_082FFE0C, - gUnknown_082FFE10, - gUnknown_082FFE14, - gUnknown_082FFE18, - gUnknown_082FFE1C, - gUnknown_082FFE20, - gUnknown_082FFE24, - gUnknown_082FFE28, - gUnknown_082FFE2C, - gUnknown_082FFE30, - gUnknown_082FFE34, - gUnknown_082FFE38, - gUnknown_082FFE3C, - gUnknown_082FFE40, - gUnknown_082FFE44, - gUnknown_082FFE48, - gUnknown_082FFE4C, - gUnknown_082FFE50, - gUnknown_082FFE54, - gUnknown_082FFE58, - gUnknown_082FFE5C, - gUnknown_082FFE60, - gUnknown_082FFE64, - gUnknown_082FFE68, - gUnknown_082FFE6C, - gUnknown_082FFE70, - gUnknown_082FFE74, - gUnknown_082FFE78, - gUnknown_082FFE7C, - gUnknown_082FFE80, - gUnknown_082FFE84, - gUnknown_082FFE88, - gUnknown_082FFE8C, - gUnknown_082FFE90, - gUnknown_082FFE94, - gUnknown_082FFE98, - gUnknown_082FFE9C, - gUnknown_082FFEA0, - gUnknown_082FFEA4, - gUnknown_082FFEA8, - gUnknown_082FFEAC, - gUnknown_082FFEB0, - gUnknown_082FFEB4, - gUnknown_082FFEB8, - gUnknown_082FFEBC, - gUnknown_082FFEC0, - gUnknown_082FFEC4, - gUnknown_082FFEC8, - gUnknown_082FFECC, - gUnknown_082FFED0, - gUnknown_082FFED4, - gUnknown_082FFED8, - gUnknown_082FFEDC, - gUnknown_082FFEE0, - gUnknown_082FFEE4, - gUnknown_082FFEE8, - gUnknown_082FFEEC, - gUnknown_082FFEF0, - gUnknown_082FFEF4, - gUnknown_082FFEF8, - gUnknown_082FFEFC, - gUnknown_082FFF00, - gUnknown_082FFF04, - gUnknown_082FFF08, - gUnknown_082FFF0C, - gUnknown_082FFF10, - gUnknown_082FFF14, - gUnknown_082FFF18, - gUnknown_082FFF1C, - gUnknown_082FFF20, - gUnknown_082FFF24, - gUnknown_082FFF28, - gUnknown_082FFF2C, - gUnknown_082FFF30, - gUnknown_082FFF34, - gUnknown_082FFF38, - gUnknown_082FFF3C, - gUnknown_082FFF40, - gUnknown_082FFF44, - gUnknown_082FFF48, - gUnknown_082FFF4C, - gUnknown_082FFF50, - gUnknown_082FFF54, - gUnknown_082FFF58, - gUnknown_082FFF5C, - gUnknown_082FFF60, - gUnknown_082FFF64, - gUnknown_082FFF68, - gUnknown_082FFF6C, - gUnknown_082FFF70, - gUnknown_082FFF74, - gUnknown_082FFF78, - gUnknown_082FFF7C, - gUnknown_082FFF80, - gUnknown_082FFF84, - gUnknown_082FFF88, - gUnknown_082FFF8C, - gUnknown_082FFF90, - gUnknown_082FFF94, - gUnknown_082FFF98, - gUnknown_082FFF9C, - gUnknown_082FFFA0, - gUnknown_082FFFA4, - gUnknown_082FFFA8, - gUnknown_082FFFAC, - gUnknown_082FFFB0, - gUnknown_082FFFB4, - gUnknown_082FFFB8, - gUnknown_082FFFBC, - gUnknown_082FFFC0, - gUnknown_082FFFC4, - gUnknown_082FFFC8, - gUnknown_082FFFCC, - gUnknown_082FFFD0, - gUnknown_082FFFD4, - gUnknown_082FFFD8, - gUnknown_082FFFDC, - gUnknown_082FFFE0, - gUnknown_082FFFE4, - gUnknown_082FFFE8, - gUnknown_082FFFEC, - gUnknown_082FFFF0, - gUnknown_082FFFF4, - gUnknown_082FFFF8, - gUnknown_082FFFFC, - gUnknown_08300000, - gUnknown_08300004, - gUnknown_08300008, - gUnknown_0830000C, - gUnknown_08300010, - gUnknown_08300014, - gUnknown_08300018, - gUnknown_0830001C, - gUnknown_08300020, - gUnknown_08300024, - gUnknown_08300028, - gUnknown_0830002C, - gUnknown_08300030, - gUnknown_08300034, - gUnknown_08300038, - gUnknown_0830003C, - gUnknown_08300040, - gUnknown_08300044, - gUnknown_08300048, - gUnknown_0830004C, - gUnknown_08300050, - gUnknown_08300054, - gUnknown_08300058, - gUnknown_0830005C, - gUnknown_08300060, - gUnknown_08300064, - gUnknown_08300068, - gUnknown_0830006C, - gUnknown_08300070, - gUnknown_08300074, - gUnknown_08300078, - gUnknown_0830007C, - gUnknown_08300080, - gUnknown_08300084, - gUnknown_08300088, - gUnknown_0830008C, - gUnknown_08300090, - gUnknown_08300094, - gUnknown_08300098, - gUnknown_0830009C, - gUnknown_083000A0, - gUnknown_083000A4, - gUnknown_083000A8, - gUnknown_083000AC, - gUnknown_083000B0, - gUnknown_083000B4, - gUnknown_083000B8, - gUnknown_083000BC, - gUnknown_083000C0, - gUnknown_083000C4, - gUnknown_083000C8, - gUnknown_083000CC, - gUnknown_083000D0, - gUnknown_083000D4, - gUnknown_083000D8, - gUnknown_083000DC, - gUnknown_083000E0, - gUnknown_083000E4, - gUnknown_083000E8, - gUnknown_083000EC, - gUnknown_083000F0, - gUnknown_083000F4, - gUnknown_083000F8, - gUnknown_083000FC, - gUnknown_08300100, - gUnknown_08300104, - gUnknown_08300108, - gUnknown_0830010C, - gUnknown_08300110, - gUnknown_08300114, - gUnknown_08300118, - gUnknown_0830011C, - gUnknown_08300120, - gUnknown_08300124, - gUnknown_08300128, - gUnknown_0830012C, - gUnknown_08300130, - gUnknown_08300134, - gUnknown_08300138, - gUnknown_0830013C, - gUnknown_08300140, - gUnknown_08300144, - gUnknown_08300148, - gUnknown_0830014C, - gUnknown_08300150, - gUnknown_08300154, - gUnknown_08300158, - gUnknown_0830015C, - gUnknown_08300160, - gUnknown_08300164, - gUnknown_08300168, - gUnknown_0830016C, - gUnknown_08300170, - gUnknown_08300174, - gUnknown_08300178, - gUnknown_0830017C, - gUnknown_08300180, - gUnknown_08300184, - gUnknown_08300188, - gUnknown_0830018C, - gUnknown_08300190, - gUnknown_08300194, - gUnknown_08300198, - gUnknown_0830019C, - gUnknown_083001A0, - gUnknown_083001A4, - gUnknown_083001A8, - gUnknown_083001AC, - gUnknown_083001B0, - gUnknown_083001B4, - gUnknown_083001B8, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001BC, - gUnknown_083001C0, - gUnknown_083001C4, - gUnknown_083001C8, - gUnknown_083001CC, - gUnknown_083001D0, - gUnknown_083001D4, - gUnknown_083001E8, - gUnknown_083001EC, - gUnknown_083001FC, - gUnknown_08300200, - gUnknown_0830020C, - gUnknown_08300214, - gUnknown_0830021C, - gUnknown_08300224, - gUnknown_08300230, - gUnknown_0830023C, - gUnknown_08300248, - gUnknown_08300254, - gUnknown_08300260, - gUnknown_08300264, - gUnknown_0830026C, - gUnknown_08300278, - gUnknown_08300280, - gUnknown_08300288, - gUnknown_08300294, - gUnknown_08300298, - gUnknown_0830029C, - gUnknown_083002A0, - gUnknown_083002A8, - gUnknown_083002B0, - gUnknown_083002B8, - gUnknown_083002C0, - gUnknown_083002C4, - gUnknown_083002CC, - gUnknown_083002D8, - gUnknown_083002E4, - gUnknown_083002F0, - gUnknown_08300304, - gUnknown_08300308, - gUnknown_08300310, - gUnknown_08300318, - gUnknown_0830032C, - gUnknown_08300334, - gUnknown_0830033C, - gUnknown_08300344, - gUnknown_08300348, - gUnknown_08300354, - gUnknown_08300358, - gUnknown_0830035C, - gUnknown_08300368, - gUnknown_0830036C, - gUnknown_08300370, - gUnknown_0830037C, - gUnknown_08300388, - gUnknown_08300394, - gUnknown_083003A0, - gUnknown_083003A8, - gUnknown_083003B0, - gUnknown_083003B8, - gUnknown_083003C0, - gUnknown_083003C8, - gUnknown_083003D4, - gUnknown_083003DC, - gUnknown_083003E8, - gUnknown_083003F0, - gUnknown_083003F8, - gUnknown_08300400, - gUnknown_0830040C, - gUnknown_08300410, - gUnknown_08300414, - gUnknown_08300418, - gUnknown_0830041C, - gUnknown_08300420, - gUnknown_08300424, - gUnknown_08300438, - gUnknown_08300444, - gUnknown_0830044C, - gUnknown_08300454, - gUnknown_0830045C, - gUnknown_08300464, - gUnknown_0830046C, - gUnknown_08300474, - gUnknown_08300480, - gUnknown_08300488, - gUnknown_08300494, - gUnknown_083004A0, - gUnknown_083004AC, - gUnknown_083004B0, - gUnknown_083004B8, - gUnknown_083004C0, - gUnknown_083004C8, - gUnknown_083004D0, - gUnknown_083004D8, - gUnknown_083004E0, - gUnknown_083004E4, - gUnknown_083004E8, - gUnknown_083004EC, - gUnknown_083004F4, - gUnknown_083004F8, - gUnknown_083004FC, - gUnknown_08300504, - gUnknown_08300510, - gUnknown_08300518, - gUnknown_0830051C, - gUnknown_08300520, - gUnknown_08300524, - gUnknown_0830052C, - gUnknown_08300534, - gUnknown_0830053C, - gUnknown_08300550, - gUnknown_08300558, - gUnknown_08300560, - gUnknown_08300564, - gUnknown_08300568, - gUnknown_0830056C, - gUnknown_08300570, - gUnknown_08300574, - gUnknown_08300578, - gUnknown_0830057C, - gUnknown_08300588, - gUnknown_0830058C, - gUnknown_08300598, - gUnknown_0830059C, - gUnknown_083005A0, - gUnknown_083005A4, - gUnknown_083005AC, - gUnknown_083005B4, - gUnknown_083005C0, - gUnknown_083005C4, - gUnknown_083005C8, - gUnknown_083005D4, - gUnknown_083005D8, - gUnknown_083005DC, - gUnknown_083005E4, - gUnknown_083005E8, - gUnknown_083005EC, - gUnknown_083005EC, - gUnknown_083005F0, - gUnknown_083005F4, - gUnknown_083005F8, - gUnknown_083005FC, - gUnknown_08300600, - gUnknown_08300604, - gUnknown_08300608, - gUnknown_0830060C, - gUnknown_08300610, - gUnknown_08300614, - gUnknown_08300618, - gUnknown_0830061C, - gUnknown_08300620, - gUnknown_08300624, - gUnknown_08300628, - gUnknown_0830062C, - gUnknown_08300630, - gUnknown_08300634, - gUnknown_08300638, - gUnknown_0830063C, - gUnknown_08300640, - gUnknown_08300644, - gUnknown_08300648, - gUnknown_0830064C, - gUnknown_08300650, - gUnknown_08300654, -}; +static const union AnimCmd *const sUnknownAnims_DEOXYS[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_CHIMECHO[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_EGG[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_C[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_D[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_E[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_F[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_G[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_H[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_I[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_J[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_K[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_L[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_M[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_N[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_O[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_P[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_Q[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_R[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_S[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_T[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_U[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_V[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_W[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_X[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_Y[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_Z[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_EMARK[] = {sAnim_GeneralFrame0}; +static const union AnimCmd *const sUnknownAnims_UNOWN_QMARK[] = {sAnim_GeneralFrame0}; + +#define ANIM_CMD(name) [SPECIES_##name] = sUnknownAnims_##name +#define ANIM_CMD_FULL(name, anims) [SPECIES_##name] = anims + +static const union AnimCmd *const *const sUnknownAnimsTable[] = +{ + ANIM_CMD(NONE), + ANIM_CMD(BULBASAUR), + ANIM_CMD(IVYSAUR), + ANIM_CMD(VENUSAUR), + ANIM_CMD(CHARMANDER), + ANIM_CMD(CHARMELEON), + ANIM_CMD(CHARIZARD), + ANIM_CMD(SQUIRTLE), + ANIM_CMD(WARTORTLE), + ANIM_CMD(BLASTOISE), + ANIM_CMD(CATERPIE), + ANIM_CMD(METAPOD), + ANIM_CMD(BUTTERFREE), + ANIM_CMD(WEEDLE), + ANIM_CMD(KAKUNA), + ANIM_CMD(BEEDRILL), + ANIM_CMD(PIDGEY), + ANIM_CMD(PIDGEOTTO), + ANIM_CMD(PIDGEOT), + ANIM_CMD(RATTATA), + ANIM_CMD(RATICATE), + ANIM_CMD(SPEAROW), + ANIM_CMD(FEAROW), + ANIM_CMD(EKANS), + ANIM_CMD(ARBOK), + ANIM_CMD(PIKACHU), + ANIM_CMD(RAICHU), + ANIM_CMD(SANDSHREW), + ANIM_CMD(SANDSLASH), + ANIM_CMD(NIDORAN_F), + ANIM_CMD(NIDORINA), + ANIM_CMD(NIDOQUEEN), + ANIM_CMD(NIDORAN_M), + ANIM_CMD(NIDORINO), + ANIM_CMD(NIDOKING), + ANIM_CMD(CLEFAIRY), + ANIM_CMD(CLEFABLE), + ANIM_CMD(VULPIX), + ANIM_CMD(NINETALES), + ANIM_CMD(JIGGLYPUFF), + ANIM_CMD(WIGGLYTUFF), + ANIM_CMD(ZUBAT), + ANIM_CMD(GOLBAT), + ANIM_CMD(ODDISH), + ANIM_CMD(GLOOM), + ANIM_CMD(VILEPLUME), + ANIM_CMD(PARAS), + ANIM_CMD(PARASECT), + ANIM_CMD(VENONAT), + ANIM_CMD(VENOMOTH), + ANIM_CMD(DIGLETT), + ANIM_CMD(DUGTRIO), + ANIM_CMD(MEOWTH), + ANIM_CMD(PERSIAN), + ANIM_CMD(PSYDUCK), + ANIM_CMD(GOLDUCK), + ANIM_CMD(MANKEY), + ANIM_CMD(PRIMEAPE), + ANIM_CMD(GROWLITHE), + ANIM_CMD(ARCANINE), + ANIM_CMD(POLIWAG), + ANIM_CMD(POLIWHIRL), + ANIM_CMD(POLIWRATH), + ANIM_CMD(ABRA), + ANIM_CMD(KADABRA), + ANIM_CMD(ALAKAZAM), + ANIM_CMD(MACHOP), + ANIM_CMD(MACHOKE), + ANIM_CMD(MACHAMP), + ANIM_CMD(BELLSPROUT), + ANIM_CMD(WEEPINBELL), + ANIM_CMD(VICTREEBEL), + ANIM_CMD(TENTACOOL), + ANIM_CMD(TENTACRUEL), + ANIM_CMD(GEODUDE), + ANIM_CMD(GRAVELER), + ANIM_CMD(GOLEM), + ANIM_CMD(PONYTA), + ANIM_CMD(RAPIDASH), + ANIM_CMD(SLOWPOKE), + ANIM_CMD(SLOWBRO), + ANIM_CMD(MAGNEMITE), + ANIM_CMD(MAGNETON), + ANIM_CMD(FARFETCHD), + ANIM_CMD(DODUO), + ANIM_CMD(DODRIO), + ANIM_CMD(SEEL), + ANIM_CMD(DEWGONG), + ANIM_CMD(GRIMER), + ANIM_CMD(MUK), + ANIM_CMD(SHELLDER), + ANIM_CMD(CLOYSTER), + ANIM_CMD(GASTLY), + ANIM_CMD(HAUNTER), + ANIM_CMD(GENGAR), + ANIM_CMD(ONIX), + ANIM_CMD(DROWZEE), + ANIM_CMD(HYPNO), + ANIM_CMD(KRABBY), + ANIM_CMD(KINGLER), + ANIM_CMD(VOLTORB), + ANIM_CMD(ELECTRODE), + ANIM_CMD(EXEGGCUTE), + ANIM_CMD(EXEGGUTOR), + ANIM_CMD(CUBONE), + ANIM_CMD(MAROWAK), + ANIM_CMD(HITMONLEE), + ANIM_CMD(HITMONCHAN), + ANIM_CMD(LICKITUNG), + ANIM_CMD(KOFFING), + ANIM_CMD(WEEZING), + ANIM_CMD(RHYHORN), + ANIM_CMD(RHYDON), + ANIM_CMD(CHANSEY), + ANIM_CMD(TANGELA), + ANIM_CMD(KANGASKHAN), + ANIM_CMD(HORSEA), + ANIM_CMD(SEADRA), + ANIM_CMD(GOLDEEN), + ANIM_CMD(SEAKING), + ANIM_CMD(STARYU), + ANIM_CMD(STARMIE), + ANIM_CMD(MR_MIME), + ANIM_CMD(SCYTHER), + ANIM_CMD(JYNX), + ANIM_CMD(ELECTABUZZ), + ANIM_CMD(MAGMAR), + ANIM_CMD(PINSIR), + ANIM_CMD(TAUROS), + ANIM_CMD(MAGIKARP), + ANIM_CMD(GYARADOS), + ANIM_CMD(LAPRAS), + ANIM_CMD(DITTO), + ANIM_CMD(EEVEE), + ANIM_CMD(VAPOREON), + ANIM_CMD(JOLTEON), + ANIM_CMD(FLAREON), + ANIM_CMD(PORYGON), + ANIM_CMD(OMANYTE), + ANIM_CMD(OMASTAR), + ANIM_CMD(KABUTO), + ANIM_CMD(KABUTOPS), + ANIM_CMD(AERODACTYL), + ANIM_CMD(SNORLAX), + ANIM_CMD(ARTICUNO), + ANIM_CMD(ZAPDOS), + ANIM_CMD(MOLTRES), + ANIM_CMD(DRATINI), + ANIM_CMD(DRAGONAIR), + ANIM_CMD(DRAGONITE), + ANIM_CMD(MEWTWO), + ANIM_CMD(MEW), + ANIM_CMD(CHIKORITA), + ANIM_CMD(BAYLEEF), + ANIM_CMD(MEGANIUM), + ANIM_CMD(CYNDAQUIL), + ANIM_CMD(QUILAVA), + ANIM_CMD(TYPHLOSION), + ANIM_CMD(TOTODILE), + ANIM_CMD(CROCONAW), + ANIM_CMD(FERALIGATR), + ANIM_CMD(SENTRET), + ANIM_CMD(FURRET), + ANIM_CMD(HOOTHOOT), + ANIM_CMD(NOCTOWL), + ANIM_CMD(LEDYBA), + ANIM_CMD(LEDIAN), + ANIM_CMD(SPINARAK), + ANIM_CMD(ARIADOS), + ANIM_CMD(CROBAT), + ANIM_CMD(CHINCHOU), + ANIM_CMD(LANTURN), + ANIM_CMD(PICHU), + ANIM_CMD(CLEFFA), + ANIM_CMD(IGGLYBUFF), + ANIM_CMD(TOGEPI), + ANIM_CMD(TOGETIC), + ANIM_CMD(NATU), + ANIM_CMD(XATU), + ANIM_CMD(MAREEP), + ANIM_CMD(FLAAFFY), + ANIM_CMD(AMPHAROS), + ANIM_CMD(BELLOSSOM), + ANIM_CMD(MARILL), + ANIM_CMD(AZUMARILL), + ANIM_CMD(SUDOWOODO), + ANIM_CMD(POLITOED), + ANIM_CMD(HOPPIP), + ANIM_CMD(SKIPLOOM), + ANIM_CMD(JUMPLUFF), + ANIM_CMD(AIPOM), + ANIM_CMD(SUNKERN), + ANIM_CMD(SUNFLORA), + ANIM_CMD(YANMA), + ANIM_CMD(WOOPER), + ANIM_CMD(QUAGSIRE), + ANIM_CMD(ESPEON), + ANIM_CMD(UMBREON), + ANIM_CMD(MURKROW), + ANIM_CMD(SLOWKING), + ANIM_CMD(MISDREAVUS), + ANIM_CMD(UNOWN), + ANIM_CMD(WOBBUFFET), + ANIM_CMD(GIRAFARIG), + ANIM_CMD(PINECO), + ANIM_CMD(FORRETRESS), + ANIM_CMD(DUNSPARCE), + ANIM_CMD(GLIGAR), + ANIM_CMD(STEELIX), + ANIM_CMD(SNUBBULL), + ANIM_CMD(GRANBULL), + ANIM_CMD(QWILFISH), + ANIM_CMD(SCIZOR), + ANIM_CMD(SHUCKLE), + ANIM_CMD(HERACROSS), + ANIM_CMD(SNEASEL), + ANIM_CMD(TEDDIURSA), + ANIM_CMD(URSARING), + ANIM_CMD(SLUGMA), + ANIM_CMD(MAGCARGO), + ANIM_CMD(SWINUB), + ANIM_CMD(PILOSWINE), + ANIM_CMD(CORSOLA), + ANIM_CMD(REMORAID), + ANIM_CMD(OCTILLERY), + ANIM_CMD(DELIBIRD), + ANIM_CMD(MANTINE), + ANIM_CMD(SKARMORY), + ANIM_CMD(HOUNDOUR), + ANIM_CMD(HOUNDOOM), + ANIM_CMD(KINGDRA), + ANIM_CMD(PHANPY), + ANIM_CMD(DONPHAN), + ANIM_CMD(PORYGON2), + ANIM_CMD(STANTLER), + ANIM_CMD(SMEARGLE), + ANIM_CMD(TYROGUE), + ANIM_CMD(HITMONTOP), + ANIM_CMD(SMOOCHUM), + ANIM_CMD(ELEKID), + ANIM_CMD(MAGBY), + ANIM_CMD(MILTANK), + ANIM_CMD(BLISSEY), + ANIM_CMD(RAIKOU), + ANIM_CMD(ENTEI), + ANIM_CMD(SUICUNE), + ANIM_CMD(LARVITAR), + ANIM_CMD(PUPITAR), + ANIM_CMD(TYRANITAR), + ANIM_CMD(LUGIA), + ANIM_CMD(HO_OH), + ANIM_CMD(CELEBI), + ANIM_CMD_FULL(OLD_UNOWN_B, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_C, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_D, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_E, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_F, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_G, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_H, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_I, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_J, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_K, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_L, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_M, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_N, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_O, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_P, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_Q, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_R, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_S, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_T, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_U, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_V, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_W, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_X, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_Y, sUnknownAnims_OLD_UNOWN), + ANIM_CMD_FULL(OLD_UNOWN_Z, sUnknownAnims_OLD_UNOWN), + ANIM_CMD(TREECKO), + ANIM_CMD(GROVYLE), + ANIM_CMD(SCEPTILE), + ANIM_CMD(TORCHIC), + ANIM_CMD(COMBUSKEN), + ANIM_CMD(BLAZIKEN), + ANIM_CMD(MUDKIP), + ANIM_CMD(MARSHTOMP), + ANIM_CMD(SWAMPERT), + ANIM_CMD(POOCHYENA), + ANIM_CMD(MIGHTYENA), + ANIM_CMD(ZIGZAGOON), + ANIM_CMD(LINOONE), + ANIM_CMD(WURMPLE), + ANIM_CMD(SILCOON), + ANIM_CMD(BEAUTIFLY), + ANIM_CMD(CASCOON), + ANIM_CMD(DUSTOX), + ANIM_CMD(LOTAD), + ANIM_CMD(LOMBRE), + ANIM_CMD(LUDICOLO), + ANIM_CMD(SEEDOT), + ANIM_CMD(NUZLEAF), + ANIM_CMD(SHIFTRY), + ANIM_CMD(NINCADA), + ANIM_CMD(NINJASK), + ANIM_CMD(SHEDINJA), + ANIM_CMD(TAILLOW), + ANIM_CMD(SWELLOW), + ANIM_CMD(SHROOMISH), + ANIM_CMD(BRELOOM), + ANIM_CMD(SPINDA), + ANIM_CMD(WINGULL), + ANIM_CMD(PELIPPER), + ANIM_CMD(SURSKIT), + ANIM_CMD(MASQUERAIN), + ANIM_CMD(WAILMER), + ANIM_CMD(WAILORD), + ANIM_CMD(SKITTY), + ANIM_CMD(DELCATTY), + ANIM_CMD(KECLEON), + ANIM_CMD(BALTOY), + ANIM_CMD(CLAYDOL), + ANIM_CMD(NOSEPASS), + ANIM_CMD(TORKOAL), + ANIM_CMD(SABLEYE), + ANIM_CMD(BARBOACH), + ANIM_CMD(WHISCASH), + ANIM_CMD(LUVDISC), + ANIM_CMD(CORPHISH), + ANIM_CMD(CRAWDAUNT), + ANIM_CMD(FEEBAS), + ANIM_CMD(MILOTIC), + ANIM_CMD(CARVANHA), + ANIM_CMD(SHARPEDO), + ANIM_CMD(TRAPINCH), + ANIM_CMD(VIBRAVA), + ANIM_CMD(FLYGON), + ANIM_CMD(MAKUHITA), + ANIM_CMD(HARIYAMA), + ANIM_CMD(ELECTRIKE), + ANIM_CMD(MANECTRIC), + ANIM_CMD(NUMEL), + ANIM_CMD(CAMERUPT), + ANIM_CMD(SPHEAL), + ANIM_CMD(SEALEO), + ANIM_CMD(WALREIN), + ANIM_CMD(CACNEA), + ANIM_CMD(CACTURNE), + ANIM_CMD(SNORUNT), + ANIM_CMD(GLALIE), + ANIM_CMD(LUNATONE), + ANIM_CMD(SOLROCK), + ANIM_CMD(AZURILL), + ANIM_CMD(SPOINK), + ANIM_CMD(GRUMPIG), + ANIM_CMD(PLUSLE), + ANIM_CMD(MINUN), + ANIM_CMD(MAWILE), + ANIM_CMD(MEDITITE), + ANIM_CMD(MEDICHAM), + ANIM_CMD(SWABLU), + ANIM_CMD(ALTARIA), + ANIM_CMD(WYNAUT), + ANIM_CMD(DUSKULL), + ANIM_CMD(DUSCLOPS), + ANIM_CMD(ROSELIA), + ANIM_CMD(SLAKOTH), + ANIM_CMD(VIGOROTH), + ANIM_CMD(SLAKING), + ANIM_CMD(GULPIN), + ANIM_CMD(SWALOT), + ANIM_CMD(TROPIUS), + ANIM_CMD(WHISMUR), + ANIM_CMD(LOUDRED), + ANIM_CMD(EXPLOUD), + ANIM_CMD(CLAMPERL), + ANIM_CMD(HUNTAIL), + ANIM_CMD(GOREBYSS), + ANIM_CMD(ABSOL), + ANIM_CMD(SHUPPET), + ANIM_CMD(BANETTE), + ANIM_CMD(SEVIPER), + ANIM_CMD(ZANGOOSE), + ANIM_CMD(RELICANTH), + ANIM_CMD(ARON), + ANIM_CMD(LAIRON), + ANIM_CMD(AGGRON), + ANIM_CMD(CASTFORM), + ANIM_CMD(VOLBEAT), + ANIM_CMD(ILLUMISE), + ANIM_CMD(LILEEP), + ANIM_CMD(CRADILY), + ANIM_CMD(ANORITH), + ANIM_CMD(ARMALDO), + ANIM_CMD(RALTS), + ANIM_CMD(KIRLIA), + ANIM_CMD(GARDEVOIR), + ANIM_CMD(BAGON), + ANIM_CMD(SHELGON), + ANIM_CMD(SALAMENCE), + ANIM_CMD(BELDUM), + ANIM_CMD(METANG), + ANIM_CMD(METAGROSS), + ANIM_CMD(REGIROCK), + ANIM_CMD(REGICE), + ANIM_CMD(REGISTEEL), + ANIM_CMD(KYOGRE), + ANIM_CMD(GROUDON), + ANIM_CMD(RAYQUAZA), + ANIM_CMD(LATIAS), + ANIM_CMD(LATIOS), + ANIM_CMD(JIRACHI), + ANIM_CMD(DEOXYS), + ANIM_CMD(CHIMECHO), + ANIM_CMD(EGG), + ANIM_CMD_FULL(UNOWN_B, sUnknownAnims_EGG), + ANIM_CMD(UNOWN_C), + ANIM_CMD(UNOWN_D), + ANIM_CMD(UNOWN_E), + ANIM_CMD(UNOWN_F), + ANIM_CMD(UNOWN_G), + ANIM_CMD(UNOWN_H), + ANIM_CMD(UNOWN_I), + ANIM_CMD(UNOWN_J), + ANIM_CMD(UNOWN_K), + ANIM_CMD(UNOWN_L), + ANIM_CMD(UNOWN_M), + ANIM_CMD(UNOWN_N), + ANIM_CMD(UNOWN_O), + ANIM_CMD(UNOWN_P), + ANIM_CMD(UNOWN_Q), + ANIM_CMD(UNOWN_R), + ANIM_CMD(UNOWN_S), + ANIM_CMD(UNOWN_T), + ANIM_CMD(UNOWN_U), + ANIM_CMD(UNOWN_V), + ANIM_CMD(UNOWN_W), + ANIM_CMD(UNOWN_X), + ANIM_CMD(UNOWN_Y), + ANIM_CMD(UNOWN_Z), + ANIM_CMD(UNOWN_EMARK), + ANIM_CMD(UNOWN_QMARK), +}; + +#undef ANIM_CMD +#undef ANIM_CMD_FULL 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/decoration.c b/src/decoration.c index fd41beb6f..c878f397a 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -43,6 +43,25 @@ #define PLACE_DECORATION_PLAYER_TAG 0x008 #define NUM_DECORATION_FLAGS (FLAG_DECORATION_14 - FLAG_DECORATION_0) +#define tCursorX data[0] +#define tCursorY data[1] +#define tState data[2] +#define tInitialX data[3] +#define tInitialY data[4] +#define tDecorWidth data[5] +#define tDecorHeight data[6] +#define tButton data[10] +#define tDecorationMenuCommand data[11] +#define tDecorationItemsMenuCommand data[12] +#define tMenuTaskId data[13] + +#define DECOR_MENU_PLACE 0 +#define DECOR_MENU_TOSS 1 +#define DECOR_MENU_TRADE 2 + +#define DECOR_ITEMS_MENU_PLACE 0 +#define DECOR_ITEMS_MENU_PUT_AWAY 1 + struct DecorationItemsMenu { struct ListMenuItem items[41]; @@ -68,6 +87,23 @@ struct DecorRearrangementDataBuffer u16 flagId; }; +struct DecorationPCContext +{ + u8 *items; + u8 *pos; + u8 size; + u8 isPlayerRoom; +}; + +enum Windows +{ + WINDOW_MAIN_MENU, + WINDOW_DECORATION_CATEGORIES, + WINDOW_DECORATION_CATEGORY_SUMMARY, + WINDOW_DECORATION_CATEGORY_ITEMS, + WINDOW_COUNT +}; + EWRAM_DATA u8 *gCurDecorationItems = NULL; EWRAM_DATA static u8 sDecorationActionsCursorPos = 0; EWRAM_DATA static u8 sNumOwnedDecorationsInCurCategory = 0; @@ -78,10 +114,10 @@ EWRAM_DATA static u16 sDecorationsScrollOffset = 0; EWRAM_DATA u8 gCurDecorationIndex = 0; EWRAM_DATA static u8 sCurDecorationCategory = DECORCAT_DESK; EWRAM_DATA static u32 filler_0203a174[2] = {}; -EWRAM_DATA struct DecorationPCContext gDecorationContext = {}; -EWRAM_DATA static u8 sDecorMenuWindowIds[4] = {}; +EWRAM_DATA static struct DecorationPCContext sDecorationContext = {}; +EWRAM_DATA static u8 sDecorMenuWindowIds[WINDOW_COUNT] = {}; EWRAM_DATA static struct DecorationItemsMenu *sDecorationItemsMenu = NULL; -EWRAM_DATA struct PlaceDecorationGraphicsDataBuffer sPlaceDecorationGraphicsDataBuffer = {}; +EWRAM_DATA static struct PlaceDecorationGraphicsDataBuffer sPlaceDecorationGraphicsDataBuffer = {}; EWRAM_DATA static u16 sCurDecorMapX = 0; EWRAM_DATA static u16 sCurDecorMapY = 0; EWRAM_DATA static u8 sDecor_CameraSpriteObjectIdx1 = 0; @@ -111,62 +147,62 @@ static void ReturnToActionsMenuFromCategories(u8 taskId); static void ExitTraderDecorationMenu(u8 taskId); static void CopyDecorationMenuItemName(u8 *dest, u16 decoration); static void DecorationItemsMenu_OnCursorMove(s32 itemIndex, bool8 flag, struct ListMenu *menu); -void sub_81274A0(u8 a0, s32 a1, u8 a2); +static void DecorationItemsMenu_PrintDecorationInUse(u8 windowId, s32 itemIndex, u8 y); static void ShowDecorationItemsWindow(u8 taskId); static void HandleDecorationItemsMenuInput(u8 taskId); -static void PrintDecorationItemDescription(u32 itemIndex); +static void PrintDecorationItemDescription(s32 itemIndex); static void RemoveDecorationItemsOtherWindows(void); -bool8 sub_81277BC(u8 idx); -bool8 sub_81277E8(u8 idx); +static bool8 IsDecorationIndexInSecretBase(u8 idx); +static bool8 IsDecorationIndexInPlayersRoom(u8 idx); static void IdentifyOwnedDecorationsCurrentlyInUse(u8 taskId); static void InitDecorationItemsWindow(u8 taskId); static void ShowDecorationCategorySummaryWindow(u8 category); -void sub_8127A30(u8 taskId); -void sub_8127A8C(u8 taskId); -void sub_8127F68(u8 taskId); -void sub_8128060(u8 taskId); -void ConfigureCameraObjectForPlacingDecoration(struct PlaceDecorationGraphicsDataBuffer *data, u8 decor); -void SetUpPlacingDecorationPlayerAvatar(u8 taskId, struct PlaceDecorationGraphicsDataBuffer *data); -void sub_812826C(u8 taskId); -void sub_81283BC(u8 taskId); -void sub_8128414(u8 taskId); -void AttemptPlaceDecoration(u8 taskId); -void PlaceDecorationPrompt(u8 taskId); -void PlaceDecoration(u8 taskId); -void sub_8128AAC(u8 taskId); -void CancelDecoratingPrompt(u8 taskId); -void CancelDecorating(u8 taskId); -void sub_8128BBC(u8 taskId); -void c1_overworld_prev_quest(u8 taskId); -void sub_8128CD4(void); -void sub_8128DE0(void); -void ContinueDecorating(u8 taskId); -void CantPlaceDecorationPrompt(u8 taskId); -void sub_81292D0(struct Sprite *sprite); -void sub_81292E8(struct Sprite *sprite); -u8 gpu_pal_decompress_alloc_tag_and_upload(struct PlaceDecorationGraphicsDataBuffer *data, u8 decor); -const u32 *GetDecorationIconPicOrPalette(u16 decor, u8 mode); -bool8 sub_81299AC(u8 taskId); -void sub_8129ABC(u8 taskId); -void ContinuePuttingAwayDecorations(u8 taskId); -void sub_8129BCC(u8 taskId); -void sub_8129BF8(u8 taskId); -void sub_8129C74(u8 taskId); -void ContinuePuttingAwayDecorationsPrompt(u8 taskId); -void sub_812A0E8(u8 taskId); -void ReturnDecorationPrompt(u8 taskId); -void PutAwayDecoration(u8 taskId); -void StopPuttingAwayDecorationsPrompt(u8 taskId); -void StopPuttingAwayDecorations(u8 taskId); -void sub_812A22C(u8 taskId); -void sub_812A25C(u8 taskId); -void sub_812A334(void); -void sub_812A36C(struct Sprite *sprite); -void sub_812A39C(void); -void sub_812A3C8(void); -void sub_812A3D4(u8 taskId); -void TossDecorationPrompt(u8 taskId); -void TossDecoration(u8 taskId); +static void DontTossDecoration(u8 taskId); +static void DecorationItemsMenuAction_Cancel(u8 taskId); +static void DecorationItemsMenuAction_AttemptPlace(u8 taskId); +static void Task_PlaceDecoration(u8 taskId); +static void ConfigureCameraObjectForPlacingDecoration(struct PlaceDecorationGraphicsDataBuffer *data, u8 decor); +static void SetUpPlacingDecorationPlayerAvatar(u8 taskId, struct PlaceDecorationGraphicsDataBuffer *data); +static void SetUpDecorationShape(u8 taskId); +static void AttemptPlaceDecoration(u8 taskId); +static void AttemptCancelPlaceDecoration(u8 taskId); +static void AttemptPlaceDecoration_(u8 taskId); +static void PlaceDecorationPrompt(u8 taskId); +static void PlaceDecoration(u8 taskId); +static void PlaceDecoration_(u8 taskId); +static void CancelDecoratingPrompt(u8 taskId); +static void CancelDecorating(u8 taskId); +static void CancelDecorating_(u8 taskId); +static void c1_overworld_prev_quest(u8 taskId); +static void FieldCB_InitDecorationItemsWindow(void); +static void ResetCursorMovement(void); +static void ContinueDecorating(u8 taskId); +static void CantPlaceDecorationPrompt(u8 taskId); +static void InitializePuttingAwayCursorSprite(struct Sprite *sprite); +static void InitializePuttingAwayCursorSprite2(struct Sprite *sprite); +static u8 gpu_pal_decompress_alloc_tag_and_upload(struct PlaceDecorationGraphicsDataBuffer *data, u8 decor); +static const u32 *GetDecorationIconPicOrPalette(u16 decor, u8 mode); +static bool8 HasDecorationsInUse(u8 taskId); +static void Task_ContinuePuttingAwayDecorations(u8 taskId); +static void ContinuePuttingAwayDecorations(u8 taskId); +static void AttemptPutAwayDecoration(u8 taskId); +static void AttemptCancelPutAwayDecoration(u8 taskId); +static void AttemptPutAwayDecoration_(u8 taskId); +static void ContinuePuttingAwayDecorationsPrompt(u8 taskId); +static void AttemptMarkDecorUnderCursorForRemoval(u8 taskId); +static void ReturnDecorationPrompt(u8 taskId); +static void PutAwayDecoration(u8 taskId); +static void StopPuttingAwayDecorationsPrompt(u8 taskId); +static void StopPuttingAwayDecorations(u8 taskId); +static void StopPuttingAwayDecorations_(u8 taskId); +static void Task_StopPuttingAwayDecorations(u8 taskId); +static void FieldCB_StopPuttingAwayDecorations(void); +static void InitializeCameraSprite1(struct Sprite *sprite); +static void LoadPlayerSpritePalette(void); +static void FreePlayerSpritePalette(void); +static void DecorationItemsMenuAction_AttemptToss(u8 taskId); +static void TossDecorationPrompt(u8 taskId); +static void TossDecoration(u8 taskId); #include "data/decoration/tiles.h" #include "data/decoration/description.h" @@ -214,19 +250,19 @@ static const u8 *const sSecretBasePCMenuItemDescriptions[] = static const TaskFunc sSecretBasePC_SelectedDecorationActions[][2] = { - { sub_8127F68, sub_8127A8C }, - { sub_812A3D4, sub_8127A8C }, - { sub_8133DA0, sub_8127A8C }, + { DecorationItemsMenuAction_AttemptPlace, DecorationItemsMenuAction_Cancel }, + { DecorationItemsMenuAction_AttemptToss, DecorationItemsMenuAction_Cancel }, + { DecorationItemsMenuAction_Trade, DecorationItemsMenuAction_Cancel }, }; -static const struct WindowTemplate sDecorationWindowTemplates[4] = +static const struct WindowTemplate sDecorationWindowTemplates[WINDOW_COUNT] = { { .bg = 0, .tilemapLeft = 1, .tilemapTop = 1, .width = 18, - .height = 8, + .height = 2 * ARRAY_COUNT(sDecorationMainMenuActions), .paletteNum = 15, .baseBlock = 0x0001 }, @@ -265,7 +301,7 @@ static const struct ListMenuTemplate sDecorationItemsListMenuTemplate = { .items = NULL, .moveCursorFunc = DecorationItemsMenu_OnCursorMove, - .itemPrintFunc = sub_81274A0, + .itemPrintFunc = DecorationItemsMenu_PrintDecorationInUse, .totalItems = 0, .maxShowed = 0, .windowId = 0, @@ -329,7 +365,7 @@ static const struct SpriteTemplate sDecorationSelectorSpriteTemplate = SpriteCallbackDummy }; -const struct SpriteTemplate sDecorWhilePlacingSpriteTemplate = +static const struct SpriteTemplate sDecorWhilePlacingSpriteTemplate = { 0x0000, 0x0000, @@ -340,33 +376,33 @@ const struct SpriteTemplate sDecorWhilePlacingSpriteTemplate = SpriteCallbackDummy }; -const struct SpritePalette gUnknown_085A72BC = +static const struct SpritePalette sSpritePal_PlaceDecoration = { .data = (const u16 *)&sPlaceDecorationGraphicsDataBuffer.palette, .tag = PLACE_DECORATION_SELECTOR_TAG, }; -const struct YesNoFuncTable sPlaceDecorationYesNoFunctions = +static const struct YesNoFuncTable sPlaceDecorationYesNoFunctions = { .yesFunc = PlaceDecoration, .noFunc = ContinueDecorating, }; -const struct YesNoFuncTable sCancelDecoratingYesNoFunctions = +static const struct YesNoFuncTable sCancelDecoratingYesNoFunctions = { .yesFunc = CancelDecorating, .noFunc = ContinueDecorating, }; -const struct YesNoFuncTable gUnknown_085A72D4[] = +static const struct YesNoFuncTable sPlacePutAwayYesNoFunctions[] = { { - .yesFunc = sub_81283BC, - .noFunc = sub_8128414, + .yesFunc = AttemptPlaceDecoration, + .noFunc = AttemptCancelPlaceDecoration, }, { - .yesFunc = sub_8129BCC, - .noFunc = sub_8129BF8, + .yesFunc = AttemptPutAwayDecoration, + .noFunc = AttemptCancelPutAwayDecoration, } }; @@ -384,41 +420,41 @@ static const u8 sDecorationSlideElevation[] = 3, 0, }; -const u16 gUnknown_085A72F4[] = { +static const u16 sDecorShapeSizes[] = { 0x04, 0x08, 0x10, 0x20, 0x10, 0x08, 0x10, 0x20, 0x40, 0x20 }; -const u16 gUnknown_085A7308[] = INCBIN_U16("graphics/decorations/unk_85a7308.gbapal"); +static const u16 sBrendanPalette[] = INCBIN_U16("graphics/decorations/brendan.gbapal"); -const u16 gUnknown_085A7328[] = INCBIN_U16("graphics/decorations/unk_85a7328.gbapal"); +static const u16 sMayPalette[] = INCBIN_U16("graphics/decorations/may.gbapal"); -const struct YesNoFuncTable sReturnDecorationYesNoFunctions = +static const struct YesNoFuncTable sReturnDecorationYesNoFunctions = { .yesFunc = PutAwayDecoration, .noFunc = ContinuePuttingAwayDecorations, }; -const struct YesNoFuncTable sStopPuttingAwayDecorationsYesNoFunctions = +static const struct YesNoFuncTable sStopPuttingAwayDecorationsYesNoFunctions = { .yesFunc = StopPuttingAwayDecorations, .noFunc = ContinuePuttingAwayDecorations, }; -const u8 gUnknown_085A7358[] = INCBIN_U8("graphics/misc/decoration_unk_85a7358.4bpp"); +static const u8 sDecorationPuttingAwayCursor[] = INCBIN_U8("graphics/misc/decoration_putting_away_cursor.4bpp"); -const struct SpritePalette gUnknown_085A73D8 = +static const struct SpritePalette sSpritePal_PuttingAwayCursorBrendan = { - .data = gUnknown_085A7308, + .data = sBrendanPalette, .tag = PLACE_DECORATION_PLAYER_TAG, }; -const struct SpritePalette gUnknown_085A73E0 = +static const struct SpritePalette sSpritePal_PuttingAwayCursorMay = { - .data = gUnknown_085A7328, + .data = sMayPalette, .tag = PLACE_DECORATION_PLAYER_TAG, }; -const struct OamData gUnknown_085A73E8 = +static const struct OamData sPuttingAwayCursorOamData = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -432,56 +468,55 @@ const struct OamData gUnknown_085A73E8 = .paletteNum = 0, }; -const union AnimCmd gUnknown_085A73F0[] = +static const union AnimCmd sPuttingAwayCursorAnimCmd0[] = { ANIMCMD_FRAME(0, 0, 0), ANIMCMD_END }; -const union AnimCmd *const gUnknown_085A73F8[] = +static const union AnimCmd *const sPuttingAwayCursorAnimCmds[] = { - gUnknown_085A73F0, + sPuttingAwayCursorAnimCmd0, }; -const struct SpriteFrameImage gUnknown_085A73FC = +static const struct SpriteFrameImage sPuttingAwayCursorPicTable = { - .data = gUnknown_085A7358, - .size = 0x80, + .data = sDecorationPuttingAwayCursor, + .size = sizeof(sDecorationPuttingAwayCursor), }; -const struct SpriteTemplate gUnknown_085A7404 = +static const struct SpriteTemplate sPuttingAwayCursorSpriteTemplate = { 0xFFFF, PLACE_DECORATION_PLAYER_TAG, - &gUnknown_085A73E8, - gUnknown_085A73F8, - &gUnknown_085A73FC, + &sPuttingAwayCursorOamData, + sPuttingAwayCursorAnimCmds, + &sPuttingAwayCursorPicTable, gDummySpriteAffineAnimTable, - sub_812A36C + InitializeCameraSprite1 }; -const struct YesNoFuncTable sTossDecorationYesNoFunctions = +static const struct YesNoFuncTable sTossDecorationYesNoFunctions = { .yesFunc = TossDecoration, - .noFunc = sub_8127A30, + .noFunc = DontTossDecoration, }; - void InitDecorationContextItems(void) { if (sCurDecorationCategory < DECORCAT_COUNT) gCurDecorationItems = gDecorationInventories[sCurDecorationCategory].items; - if (gDecorationContext.isPlayerRoom == FALSE) + if (sDecorationContext.isPlayerRoom == FALSE) { - gDecorationContext.items = gSaveBlock1Ptr->secretBases[0].decorations; - gDecorationContext.pos = gSaveBlock1Ptr->secretBases[0].decorationPositions; + sDecorationContext.items = gSaveBlock1Ptr->secretBases[0].decorations; + sDecorationContext.pos = gSaveBlock1Ptr->secretBases[0].decorationPositions; } - if (gDecorationContext.isPlayerRoom == TRUE) + if (sDecorationContext.isPlayerRoom == TRUE) { - gDecorationContext.items = gSaveBlock1Ptr->playerRoomDecor; - gDecorationContext.pos = gSaveBlock1Ptr->playerRoomDecorPos; + sDecorationContext.items = gSaveBlock1Ptr->playerRoomDecorations; + sDecorationContext.pos = gSaveBlock1Ptr->playerRoomDecorationPositions; } } @@ -491,9 +526,9 @@ static u8 AddDecorationWindow(u8 windowIndex) struct WindowTemplate template; windowId = &sDecorMenuWindowIds[windowIndex]; - if (windowIndex == 0) + if (windowIndex == WINDOW_MAIN_MENU) { - template = sDecorationWindowTemplates[0]; + template = sDecorationWindowTemplates[WINDOW_MAIN_MENU]; template.width = GetMaxWidthInMenuTable(sDecorationMainMenuActions, ARRAY_COUNT(sDecorationMainMenuActions)); if (template.width > 18) template.width = 18; @@ -520,9 +555,9 @@ static void RemoveDecorationWindow(u8 windowIndex) static void AddDecorationActionsWindow(void) { - u8 windowId = AddDecorationWindow(0); - PrintMenuTable(windowId, 4, sDecorationMainMenuActions); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, 4, sDecorationActionsCursorPos); + u8 windowId = AddDecorationWindow(WINDOW_MAIN_MENU); + PrintMenuTable(windowId, ARRAY_COUNT(sDecorationMainMenuActions), sDecorationMainMenuActions); + InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, ARRAY_COUNT(sDecorationMainMenuActions), sDecorationActionsCursorPos); } static void InitDecorationActionsWindow(void) @@ -536,20 +571,20 @@ static void InitDecorationActionsWindow(void) void DoSecretBaseDecorationMenu(u8 taskId) { InitDecorationActionsWindow(); - gDecorationContext.items = gSaveBlock1Ptr->secretBases[0].decorations; - gDecorationContext.pos = gSaveBlock1Ptr->secretBases[0].decorationPositions; - gDecorationContext.size = sizeof(gSaveBlock1Ptr->secretBases[0].decorations); - gDecorationContext.isPlayerRoom = FALSE; + sDecorationContext.items = gSaveBlock1Ptr->secretBases[0].decorations; + sDecorationContext.pos = gSaveBlock1Ptr->secretBases[0].decorationPositions; + sDecorationContext.size = DECOR_MAX_SECRET_BASE; + sDecorationContext.isPlayerRoom = FALSE; gTasks[taskId].func = HandleDecorationActionsMenuInput; } void DoPlayerRoomDecorationMenu(u8 taskId) { InitDecorationActionsWindow(); - gDecorationContext.items = gSaveBlock1Ptr->playerRoomDecor; - gDecorationContext.pos = gSaveBlock1Ptr->playerRoomDecorPos; - gDecorationContext.size = sizeof(gSaveBlock1Ptr->playerRoomDecor); - gDecorationContext.isPlayerRoom = TRUE; + sDecorationContext.items = gSaveBlock1Ptr->playerRoomDecorations; + sDecorationContext.pos = gSaveBlock1Ptr->playerRoomDecorationPositions; + sDecorationContext.size = DECOR_MAX_PLAYERS_HOUSE; + sDecorationContext.isPlayerRoom = TRUE; gTasks[taskId].func = HandleDecorationActionsMenuInput; } @@ -592,7 +627,7 @@ static void DecorationMenuAction_Decorate(u8 taskId) } else { - gTasks[taskId].data[11] = 0; + gTasks[taskId].tDecorationMenuCommand = DECOR_MENU_PLACE; sCurDecorationCategory = DECORCAT_DESK; SecretBasePC_PrepMenuForSelectingStoredDecors(taskId); } @@ -600,18 +635,18 @@ static void DecorationMenuAction_Decorate(u8 taskId) static void DecorationMenuAction_PutAway(u8 taskId) { - if (!sub_81299AC(taskId)) + if (!HasDecorationsInUse(taskId)) { StringExpandPlaceholders(gStringVar4, gText_NoDecorationsInUse); DisplayItemMessageOnField(taskId, gStringVar4, ReturnToDecorationActionsAfterInvalidSelection); } else { - RemoveDecorationWindow(0); + RemoveDecorationWindow(WINDOW_MAIN_MENU); ClearDialogWindowAndFrame(0, 0); FadeScreen(FADE_TO_BLACK, 0); - gTasks[taskId].data[2] = 0; - gTasks[taskId].func = sub_8129ABC; + gTasks[taskId].tState = 0; + gTasks[taskId].func = Task_ContinuePuttingAwayDecorations; } } @@ -624,7 +659,7 @@ static void DecorationMenuAction_Toss(u8 taskId) } else { - gTasks[taskId].data[11] = 1; + gTasks[taskId].tDecorationMenuCommand = DECOR_MENU_TOSS; sCurDecorationCategory = DECORCAT_DESK; SecretBasePC_PrepMenuForSelectingStoredDecors(taskId); } @@ -632,8 +667,8 @@ static void DecorationMenuAction_Toss(u8 taskId) static void DecorationMenuAction_Cancel(u8 taskId) { - RemoveDecorationWindow(0); - if (!gDecorationContext.isPlayerRoom) + RemoveDecorationWindow(WINDOW_MAIN_MENU); + if (!sDecorationContext.isPlayerRoom) { ScriptContext1_SetupScript(SecretBase_EventScript_PCCancel); DestroyTask(taskId); @@ -654,23 +689,23 @@ static void SecretBasePC_PrepMenuForSelectingStoredDecors(u8 taskId) { LoadPalette(sDecorationMenuPalette, 0xd0, 0x20); ClearDialogWindowAndFrame(0, 0); - RemoveDecorationWindow(0); + RemoveDecorationWindow(WINDOW_MAIN_MENU); InitDecorationCategoriesWindow(taskId); } static void InitDecorationCategoriesWindow(u8 taskId) { - u8 windowId = AddDecorationWindow(1); + u8 windowId = AddDecorationWindow(WINDOW_DECORATION_CATEGORIES); PrintDecorationCategoryMenuItems(taskId); InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, DECORCAT_COUNT + 1, sCurDecorationCategory); gTasks[taskId].func = HandleDecorationCategoriesMenuInput; } -static void sub_8126E44(u8 taskId) +static void ReinitDecorationCategoriesWindow(u8 taskId) { - FillWindowPixelBuffer(sDecorMenuWindowIds[1], PIXEL_FILL(1)); + FillWindowPixelBuffer(sDecorMenuWindowIds[WINDOW_DECORATION_CATEGORIES], PIXEL_FILL(1)); PrintDecorationCategoryMenuItems(taskId); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sDecorMenuWindowIds[1], DECORCAT_COUNT + 1, sCurDecorationCategory); + InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sDecorMenuWindowIds[WINDOW_DECORATION_CATEGORIES], DECORCAT_COUNT + 1, sCurDecorationCategory); gTasks[taskId].func = HandleDecorationCategoriesMenuInput; } @@ -678,10 +713,10 @@ static void PrintDecorationCategoryMenuItems(u8 taskId) { u8 i; s16 *data = gTasks[taskId].data; - u8 windowId = sDecorMenuWindowIds[1]; - bool8 isPlayerRoom = gDecorationContext.isPlayerRoom; + u8 windowId = sDecorMenuWindowIds[WINDOW_DECORATION_CATEGORIES]; + bool8 isPlayerRoom = sDecorationContext.isPlayerRoom; bool8 shouldDisable = FALSE; - if (isPlayerRoom == TRUE && data[11] == 0) + if (isPlayerRoom == TRUE && tDecorationMenuCommand == DECOR_MENU_PLACE) shouldDisable = TRUE; for (i = 0; i < DECORCAT_COUNT; i++) @@ -693,7 +728,7 @@ static void PrintDecorationCategoryMenuItems(u8 taskId) PrintDecorationCategoryMenuItem(windowId, i, 8, i * 16, FALSE, TEXT_SPEED_FF); } - AddTextPrinterParameterized(windowId, 1, gTasks[taskId].data[11] == 2 ? gText_Exit : gText_Cancel, 8, i * 16 + 1, 0, NULL); + AddTextPrinterParameterized(windowId, 1, gTasks[taskId].tDecorationMenuCommand == DECOR_MENU_TRADE ? gText_Exit : gText_Cancel, 8, i * 16 + 1, 0, NULL); schedule_bg_copy_tilemap_to_vram(0); } @@ -767,7 +802,7 @@ static void SelectDecorationCategory(u8 taskId) } else { - RemoveDecorationWindow(1); + RemoveDecorationWindow(WINDOW_DECORATION_CATEGORIES); StringExpandPlaceholders(gStringVar4, gText_NoDecorations); DisplayItemMessageOnField(taskId, gStringVar4, ReturnToDecorationCategoriesAfterInvalidSelection); } @@ -781,7 +816,7 @@ static void ReturnToDecorationCategoriesAfterInvalidSelection(u8 taskId) static void ExitDecorationCategoriesMenu(u8 taskId) { - if (gTasks[taskId].data[11] != 2) + if (gTasks[taskId].tDecorationMenuCommand != DECOR_MENU_TRADE) ReturnToActionsMenuFromCategories(taskId); else ExitTraderDecorationMenu(taskId); @@ -789,7 +824,7 @@ static void ExitDecorationCategoriesMenu(u8 taskId) static void ReturnToActionsMenuFromCategories(u8 taskId) { - RemoveDecorationWindow(1); + RemoveDecorationWindow(WINDOW_DECORATION_CATEGORIES); AddDecorationActionsWindow(); DrawDialogueFrame(0, 0); PrintCurMainMenuDescription(); @@ -800,7 +835,7 @@ void ShowDecorationCategoriesWindow(u8 taskId) { LoadPalette(sDecorationMenuPalette, 0xd0, 0x20); ClearDialogWindowAndFrame(0, 0); - gTasks[taskId].data[11] = 2; + gTasks[taskId].tDecorationMenuCommand = DECOR_MENU_TRADE; sCurDecorationCategory = DECORCAT_DESK; InitDecorationCategoriesWindow(taskId); } @@ -812,7 +847,7 @@ void CopyDecorationCategoryName(u8 *dest, u8 category) static void ExitTraderDecorationMenu(u8 taskId) { - RemoveDecorationWindow(1); + RemoveDecorationWindow(WINDOW_DECORATION_CATEGORIES); ExitTraderMenu(taskId); } @@ -825,12 +860,12 @@ static void InitDecorationItemsMenuLimits(void) sDecorationItemsMenu->maxShownItems = sDecorationItemsMenu->numMenuItems; } -static void sub_81272C8(void) +static void InitDecorationItemsMenuScrollAndCursor(void) { sub_812225C(&sDecorationsScrollOffset, &sDecorationsCursorPos, sDecorationItemsMenu->maxShownItems, sDecorationItemsMenu->numMenuItems); } -static void sub_81272F8(void) +static void InitDecorationItemsMenuScrollAndCursor2(void) { sub_8122298(&sDecorationsScrollOffset, &sDecorationsCursorPos, sDecorationItemsMenu->maxShownItems, sDecorationItemsMenu->numMenuItems, 8); } @@ -841,7 +876,7 @@ static void PrintDecorationItemMenuItems(u8 taskId) u16 i; data = gTasks[taskId].data; - if ((sCurDecorationCategory < DECORCAT_DOLL || sCurDecorationCategory > DECORCAT_CUSHION) && gDecorationContext.isPlayerRoom == TRUE && data[11] == 0) + if ((sCurDecorationCategory < DECORCAT_DOLL || sCurDecorationCategory > DECORCAT_CUSHION) && sDecorationContext.isPlayerRoom == TRUE && tDecorationMenuCommand == DECOR_MENU_PLACE) ColorMenuItemString(gStringVar1, TRUE); else ColorMenuItemString(gStringVar1, FALSE); @@ -857,7 +892,7 @@ static void PrintDecorationItemMenuItems(u8 taskId) sDecorationItemsMenu->items[i].name = sDecorationItemsMenu->names[i]; sDecorationItemsMenu->items[i].id = -2; gMultiuseListMenuTemplate = sDecorationItemsListMenuTemplate; - gMultiuseListMenuTemplate.windowId = sDecorMenuWindowIds[1]; + gMultiuseListMenuTemplate.windowId = sDecorMenuWindowIds[WINDOW_DECORATION_CATEGORIES]; gMultiuseListMenuTemplate.totalItems = sDecorationItemsMenu->numMenuItems; gMultiuseListMenuTemplate.items = sDecorationItemsMenu->items; gMultiuseListMenuTemplate.maxShowed = sDecorationItemsMenu->maxShownItems; @@ -877,18 +912,14 @@ static void DecorationItemsMenu_OnCursorMove(s32 itemIndex, bool8 flag, struct L PrintDecorationItemDescription(itemIndex); } -void sub_81274A0(u8 a0, s32 a1, u8 a2) +static void DecorationItemsMenu_PrintDecorationInUse(u8 windowId, s32 itemIndex, u8 y) { - if (a1 != -2) + if (itemIndex != -2) { - if (sub_81277BC(a1 + 1) == TRUE) - { - blit_move_info_icon(a0, 0x18, 0x5c, a2 + 2); - } - else if (sub_81277E8(a1 + 1) == TRUE) - { - blit_move_info_icon(a0, 0x19, 0x5c, a2 + 2); - } + if (IsDecorationIndexInSecretBase(itemIndex + 1) == TRUE) + blit_move_info_icon(windowId, 0x18, 0x5c, y + 2); + else if (IsDecorationIndexInPlayersRoom(itemIndex + 1) == TRUE) + blit_move_info_icon(windowId, 0x19, 0x5c, y + 2); } } @@ -917,24 +948,24 @@ static void RemoveDecorationItemsScrollIndicators(void) } } -void sub_8127580(u8 taskId) +static void AddDecorationItemsWindow(u8 taskId) { - AddDecorationWindow(1); + AddDecorationWindow(WINDOW_DECORATION_CATEGORIES); InitDecorationItemsWindow(taskId); } static void InitDecorationItemsWindow(u8 taskId) { s16 *data = gTasks[taskId].data; - AddDecorationWindow(3); + AddDecorationWindow(WINDOW_DECORATION_CATEGORY_ITEMS); ShowDecorationCategorySummaryWindow(sCurDecorationCategory); sDecorationItemsMenu = AllocZeroed(sizeof(*sDecorationItemsMenu)); sDecorationItemsMenu->scrollIndicatorsTaskId = 0xFF; InitDecorationItemsMenuLimits(); - sub_81272C8(); - sub_81272F8(); + InitDecorationItemsMenuScrollAndCursor(); + InitDecorationItemsMenuScrollAndCursor2(); PrintDecorationItemMenuItems(taskId); - data[13] = ListMenuInit(&gMultiuseListMenuTemplate, sDecorationsScrollOffset, sDecorationsCursorPos); + tMenuTaskId = ListMenuInit(&gMultiuseListMenuTemplate, sDecorationsScrollOffset, sDecorationsCursorPos); AddDecorationItemsScrollIndicators(); } @@ -952,25 +983,25 @@ static void HandleDecorationItemsMenuInput(u8 taskId) data = gTasks[taskId].data; if (!gPaletteFade.active) { - input = ListMenu_ProcessInput(data[13]); - ListMenuGetScrollAndRow(data[13], &sDecorationsScrollOffset, &sDecorationsCursorPos); + input = ListMenu_ProcessInput(tMenuTaskId); + ListMenuGetScrollAndRow(tMenuTaskId, &sDecorationsScrollOffset, &sDecorationsCursorPos); switch (input) { case LIST_NOTHING_CHOSEN: break; case LIST_CANCEL: PlaySE(SE_SELECT); - sSecretBasePC_SelectedDecorationActions[data[11]][1](taskId); + sSecretBasePC_SelectedDecorationActions[tDecorationMenuCommand][1](taskId); break; default: PlaySE(SE_SELECT); gCurDecorationIndex = input; RemoveDecorationItemsScrollIndicators(); - DestroyListMenuTask(data[13], &sDecorationsScrollOffset, &sDecorationsCursorPos); - RemoveDecorationWindow(1); + DestroyListMenuTask(tMenuTaskId, &sDecorationsScrollOffset, &sDecorationsCursorPos); + RemoveDecorationWindow(WINDOW_DECORATION_CATEGORIES); RemoveDecorationItemsOtherWindows(); free(sDecorationItemsMenu); - sSecretBasePC_SelectedDecorationActions[data[11]][0](taskId); + sSecretBasePC_SelectedDecorationActions[tDecorationMenuCommand][0](taskId); break; } } @@ -978,17 +1009,17 @@ static void HandleDecorationItemsMenuInput(u8 taskId) static void ShowDecorationCategorySummaryWindow(u8 category) { - PrintDecorationCategoryMenuItem(AddDecorationWindow(2), category, 0, 0, 0, 0); + PrintDecorationCategoryMenuItem(AddDecorationWindow(WINDOW_DECORATION_CATEGORY_SUMMARY), category, 0, 0, 0, 0); } -static void PrintDecorationItemDescription(u32 itemIndex) +static void PrintDecorationItemDescription(s32 itemIndex) { u8 windowId; const u8 *str; - windowId = sDecorMenuWindowIds[3]; + windowId = sDecorMenuWindowIds[WINDOW_DECORATION_CATEGORY_ITEMS]; FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); - if (itemIndex >= sNumOwnedDecorationsInCurCategory) + if ((u32)itemIndex >= sNumOwnedDecorationsInCurCategory) str = gText_GoBackPrevMenu; else str = gDecorations[gCurDecorationItems[itemIndex]].description; @@ -998,12 +1029,11 @@ static void PrintDecorationItemDescription(u32 itemIndex) static void RemoveDecorationItemsOtherWindows(void) { - // Remove description and category summary windows - RemoveDecorationWindow(3); - RemoveDecorationWindow(2); + RemoveDecorationWindow(WINDOW_DECORATION_CATEGORY_ITEMS); + RemoveDecorationWindow(WINDOW_DECORATION_CATEGORY_SUMMARY); } -bool8 sub_81277BC(u8 idx) +static bool8 IsDecorationIndexInSecretBase(u8 idx) { u8 i; for (i = 0; i < ARRAY_COUNT(sSecretBaseItemsIndicesBuffer); i++) @@ -1015,7 +1045,7 @@ bool8 sub_81277BC(u8 idx) return FALSE; } -bool8 sub_81277E8(u8 idx) +static bool8 IsDecorationIndexInPlayersRoom(u8 idx) { u8 i; for (i = 0; i < ARRAY_COUNT(sPlayerRoomItemsIndicesBuffer); i++) @@ -1061,11 +1091,11 @@ static void IdentifyOwnedDecorationsCurrentlyInUseInternal(u8 taskId) count = 0; for (i = 0; i < ARRAY_COUNT(sPlayerRoomItemsIndicesBuffer); i++) { - if (gSaveBlock1Ptr->playerRoomDecor[i] != DECOR_NONE) + if (gSaveBlock1Ptr->playerRoomDecorations[i] != DECOR_NONE) { for (j = 0; j < gDecorationInventories[sCurDecorationCategory].size; j++) { - if (gCurDecorationItems[j] == gSaveBlock1Ptr->playerRoomDecor[i] && sub_81277BC(j + 1) != TRUE) + if (gCurDecorationItems[j] == gSaveBlock1Ptr->playerRoomDecorations[i] && IsDecorationIndexInSecretBase(j + 1) != TRUE) { for (k = 0; k < count && sPlayerRoomItemsIndicesBuffer[k] != j + 1; k++); if (k == count) @@ -1103,49 +1133,49 @@ bool8 IsSelectedDecorInThePC(void) return TRUE; } -static void sub_8127A14(u8 taskId) +static void Task_ShowDecorationItemsWindow(u8 taskId) { - AddDecorationWindow(1); + AddDecorationWindow(WINDOW_DECORATION_CATEGORIES); ShowDecorationItemsWindow(taskId); } -void sub_8127A30(u8 taskId) +static void DontTossDecoration(u8 taskId) { ClearDialogWindowAndFrame(0, 0); - gTasks[taskId].func = sub_8127A14; + gTasks[taskId].func = Task_ShowDecorationItemsWindow; } -void sub_8127A5C(u8 taskId) +static void ReturnToDecorationItemsAfterInvalidSelection(u8 taskId) { if (gMain.newKeys & (A_BUTTON | B_BUTTON)) { ClearDialogWindowAndFrame(0, 0); - AddDecorationWindow(1); + AddDecorationWindow(WINDOW_DECORATION_CATEGORIES); ShowDecorationItemsWindow(taskId); } } -void sub_8127A8C(u8 taskId) +static void DecorationItemsMenuAction_Cancel(u8 taskId) { s16 *data = gTasks[taskId].data; RemoveDecorationItemsScrollIndicators(); RemoveDecorationItemsOtherWindows(); - DestroyListMenuTask(data[13], NULL, NULL); + DestroyListMenuTask(tMenuTaskId, NULL, NULL); free(sDecorationItemsMenu); - sub_8126E44(taskId); + ReinitDecorationCategoriesWindow(taskId); } -void sub_8127ACC(u8 taskId) +static void SetInitialPositions(u8 taskId) { - gTasks[taskId].data[3] = gSaveBlock1Ptr->pos.x; - gTasks[taskId].data[4] = gSaveBlock1Ptr->pos.y; - PlayerGetDestCoords(&gTasks[taskId].data[0], &gTasks[taskId].data[1]); + gTasks[taskId].tInitialX = gSaveBlock1Ptr->pos.x; + gTasks[taskId].tInitialY = gSaveBlock1Ptr->pos.y; + PlayerGetDestCoords(&gTasks[taskId].tCursorX, &gTasks[taskId].tCursorY); } -void sub_8127B04(u8 taskId) +static void WarpToInitialPosition(u8 taskId) { DrawWholeMapView(); - SetWarpDestination(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, gTasks[taskId].data[3], gTasks[taskId].data[4]); + SetWarpDestination(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, gTasks[taskId].tInitialX, gTasks[taskId].tInitialY); WarpIntoMap(); } @@ -1155,10 +1185,10 @@ static u16 GetDecorationElevation(u8 decoration, u8 tileIndex) switch (decoration) { case DECOR_STAND: - elevation = sDecorationStandElevations[tileIndex] << 12; + elevation = sDecorationStandElevations[tileIndex] << METATILE_ELEVATION_SHIFT; return elevation; case DECOR_SLIDE: - elevation = sDecorationSlideElevation[tileIndex] << 12; + elevation = sDecorationSlideElevation[tileIndex] << METATILE_ELEVATION_SHIFT; return elevation; default: return elevation; @@ -1171,7 +1201,7 @@ static void ShowDecorationOnMap_(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight, s16 x, y; u16 behavior; u16 impassableFlag; - u16 posterSide; + u16 overlapsWall; u16 elevation; for (j = 0; j < decHeight; j++) @@ -1181,21 +1211,22 @@ static void ShowDecorationOnMap_(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight, { x = mapX + i; behavior = GetBehaviorByMetatileId(0x200 + gDecorations[decoration].tiles[j * decWidth + i]); - if (MetatileBehavior_IsSecretBaseImpassable(behavior) == TRUE || (gDecorations[decoration].permission != DECORPERM_PASS_FLOOR && (behavior >> 12))) + if (MetatileBehavior_IsSecretBaseImpassable(behavior) == TRUE || (gDecorations[decoration].permission != DECORPERM_PASS_FLOOR && (behavior >> METATILE_ELEVATION_SHIFT))) impassableFlag = METATILE_COLLISION_MASK; else impassableFlag = 0; + // Choose the metatile that has the wall background instead of the floor if overlapping a wall. if (gDecorations[decoration].permission != DECORPERM_NA_WALL && MetatileBehavior_IsSecretBaseNorthWall(MapGridGetMetatileBehaviorAt(x, y)) == TRUE) - posterSide = 1; + overlapsWall = 1; else - posterSide = 0; + overlapsWall = 0; elevation = GetDecorationElevation(gDecorations[decoration].id, j * decWidth + i); if (elevation != 0xFFFF) - MapGridSetMetatileEntryAt(x, y, (gDecorations[decoration].tiles[j * decWidth + i] + (0x200 | posterSide)) | impassableFlag | elevation); + MapGridSetMetatileEntryAt(x, y, (gDecorations[decoration].tiles[j * decWidth + i] + (0x200 | overlapsWall)) | impassableFlag | elevation); else - MapGridSetMetatileIdAt(x, y, (gDecorations[decoration].tiles[j * decWidth + i] + (0x200 | posterSide)) | impassableFlag); + MapGridSetMetatileIdAt(x, y, (gDecorations[decoration].tiles[j * decWidth + i] + (0x200 | overlapsWall)) | impassableFlag); } } } @@ -1268,100 +1299,98 @@ void SetDecoration(void) } } -bool8 sub_8127F38(void) +static bool8 HasDecorationSpace(void) { u16 i; - - for (i = 0; i < gDecorationContext.size; i++) + for (i = 0; i < sDecorationContext.size; i++) { - if (gDecorationContext.items[i] == DECOR_NONE) - { + if (sDecorationContext.items[i] == DECOR_NONE) return TRUE; - } } + return FALSE; } -void sub_8127F68(u8 taskId) +static void DecorationItemsMenuAction_AttemptPlace(u8 taskId) { - if (gDecorationContext.isPlayerRoom == TRUE && sCurDecorationCategory != DECORCAT_DOLL && sCurDecorationCategory != DECORCAT_CUSHION) + if (sDecorationContext.isPlayerRoom == TRUE && sCurDecorationCategory != DECORCAT_DOLL && sCurDecorationCategory != DECORCAT_CUSHION) { StringExpandPlaceholders(gStringVar4, gText_CantPlaceInRoom); - DisplayItemMessageOnField(taskId, gStringVar4, sub_8127A5C); + DisplayItemMessageOnField(taskId, gStringVar4, ReturnToDecorationItemsAfterInvalidSelection); } else if (IsSelectedDecorInThePC() == TRUE) { - if (sub_8127F38() == TRUE) + if (HasDecorationSpace() == TRUE) { FadeScreen(FADE_TO_BLACK, 0); - gTasks[taskId].data[2] = 0; - gTasks[taskId].func = sub_8128060; + gTasks[taskId].tState = 0; + gTasks[taskId].func = Task_PlaceDecoration; } else { - ConvertIntToDecimalStringN(gStringVar1, gDecorationContext.size, STR_CONV_MODE_RIGHT_ALIGN, 2); - if (gDecorationContext.isPlayerRoom == FALSE) { + ConvertIntToDecimalStringN(gStringVar1, sDecorationContext.size, STR_CONV_MODE_RIGHT_ALIGN, 2); + if (sDecorationContext.isPlayerRoom == FALSE) { StringExpandPlaceholders(gStringVar4, gText_NoMoreDecorations); } else { StringExpandPlaceholders(gStringVar4, gText_NoMoreDecorations2); } - DisplayItemMessageOnField(taskId, gStringVar4, sub_8127A5C); + DisplayItemMessageOnField(taskId, gStringVar4, ReturnToDecorationItemsAfterInvalidSelection); } } else { StringExpandPlaceholders(gStringVar4, gText_InUseAlready); - DisplayItemMessageOnField(taskId, gStringVar4, sub_8127A5C); + DisplayItemMessageOnField(taskId, gStringVar4, ReturnToDecorationItemsAfterInvalidSelection); } } -void sub_8128060(u8 taskId) +static void Task_PlaceDecoration(u8 taskId) { - switch (gTasks[taskId].data[2]) + switch (gTasks[taskId].tState) { case 0: if (!gPaletteFade.active) { - sub_8127ACC(taskId); - gTasks[taskId].data[2] = 1; + SetInitialPositions(taskId); + gTasks[taskId].tState = 1; } break; case 1: gPaletteFade.bufferTransferDisabled = TRUE; ConfigureCameraObjectForPlacingDecoration(&sPlaceDecorationGraphicsDataBuffer, gCurDecorationItems[gCurDecorationIndex]); - sub_812826C(taskId); + SetUpDecorationShape(taskId); SetUpPlacingDecorationPlayerAvatar(taskId, &sPlaceDecorationGraphicsDataBuffer); FadeInFromBlack(); gPaletteFade.bufferTransferDisabled = FALSE; - gTasks[taskId].data[2] = 2; + gTasks[taskId].tState = 2; break; case 2: if (IsWeatherNotFadingIn() == TRUE) { - gTasks[taskId].data[12] = 0; + gTasks[taskId].tDecorationItemsMenuCommand = DECOR_ITEMS_MENU_PLACE; ContinueDecorating(taskId); } break; } } -void ConfigureCameraObjectForPlacingDecoration(struct PlaceDecorationGraphicsDataBuffer *data, u8 decor) +static void ConfigureCameraObjectForPlacingDecoration(struct PlaceDecorationGraphicsDataBuffer *data, u8 decor) { sDecor_CameraSpriteObjectIdx1 = gSprites[gFieldCamera.spriteId].data[0]; gFieldCamera.spriteId = gpu_pal_decompress_alloc_tag_and_upload(data, decor); gSprites[gFieldCamera.spriteId].oam.priority = 1; - gSprites[gFieldCamera.spriteId].callback = sub_81292D0; + gSprites[gFieldCamera.spriteId].callback = InitializePuttingAwayCursorSprite; gSprites[gFieldCamera.spriteId].pos1.x = sDecorationMovementInfo[data->decoration->shape].cameraX; gSprites[gFieldCamera.spriteId].pos1.y = sDecorationMovementInfo[data->decoration->shape].cameraY; } -void SetUpPlacingDecorationPlayerAvatar(u8 taskId, struct PlaceDecorationGraphicsDataBuffer *data) +static void SetUpPlacingDecorationPlayerAvatar(u8 taskId, struct PlaceDecorationGraphicsDataBuffer *data) { u8 x; - x = 16 * (u8)gTasks[taskId].data[5] + sDecorationMovementInfo[data->decoration->shape].cameraX - 8 * ((u8)gTasks[taskId].data[5] - 1); + x = 16 * (u8)gTasks[taskId].tDecorWidth + sDecorationMovementInfo[data->decoration->shape].cameraX - 8 * ((u8)gTasks[taskId].tDecorWidth - 1); if (data->decoration->shape == DECORSHAPE_3x1 || data->decoration->shape == DECORSHAPE_3x3 || data->decoration->shape == DECORSHAPE_3x2) x -= 8; @@ -1375,92 +1404,89 @@ void SetUpPlacingDecorationPlayerAvatar(u8 taskId, struct PlaceDecorationGraphic sDecor_CameraSpriteObjectIdx1 = gFieldCamera.spriteId; } -void sub_812826C(u8 taskId) +static void SetUpDecorationShape(u8 taskId) { switch (gDecorations[gCurDecorationItems[gCurDecorationIndex]].shape) { case DECORSHAPE_1x1: - gTasks[taskId].data[5] = 1; - gTasks[taskId].data[6] = 1; + gTasks[taskId].tDecorWidth = 1; + gTasks[taskId].tDecorHeight = 1; break; case DECORSHAPE_2x1: - gTasks[taskId].data[5] = 2; - gTasks[taskId].data[6] = 1; + gTasks[taskId].tDecorWidth = 2; + gTasks[taskId].tDecorHeight = 1; break; case DECORSHAPE_3x1: - gTasks[taskId].data[5] = 3; - gTasks[taskId].data[6] = 1; + gTasks[taskId].tDecorWidth = 3; + gTasks[taskId].tDecorHeight = 1; break; case DECORSHAPE_4x2: - gTasks[taskId].data[5] = 4; - gTasks[taskId].data[6] = 2; + gTasks[taskId].tDecorWidth = 4; + gTasks[taskId].tDecorHeight = 2; break; case DECORSHAPE_2x2: - gTasks[taskId].data[5] = 2; - gTasks[taskId].data[6] = 2; + gTasks[taskId].tDecorWidth = 2; + gTasks[taskId].tDecorHeight = 2; break; case DECORSHAPE_1x2: - gTasks[taskId].data[5] = 1; - gTasks[taskId].data[6] = 2; + gTasks[taskId].tDecorWidth = 1; + gTasks[taskId].tDecorHeight = 2; break; case DECORSHAPE_1x3: - gTasks[taskId].data[5] = 1; - gTasks[taskId].data[6] = 3; - gTasks[taskId].data[1]++; + gTasks[taskId].tDecorWidth = 1; + gTasks[taskId].tDecorHeight = 3; + gTasks[taskId].tCursorY++; break; case DECORSHAPE_2x4: - gTasks[taskId].data[5] = 2; - gTasks[taskId].data[6] = 4; + gTasks[taskId].tDecorWidth = 2; + gTasks[taskId].tDecorHeight = 4; break; case DECORSHAPE_3x3: - gTasks[taskId].data[5] = 3; - gTasks[taskId].data[6] = 3; + gTasks[taskId].tDecorWidth = 3; + gTasks[taskId].tDecorHeight = 3; break; case DECORSHAPE_3x2: - gTasks[taskId].data[5] = 3; - gTasks[taskId].data[6] = 2; + gTasks[taskId].tDecorWidth = 3; + gTasks[taskId].tDecorHeight = 2; break; } } -void sub_81283BC(u8 taskId) +static void AttemptPlaceDecoration(u8 taskId) { - gTasks[taskId].data[10] = 0; + gTasks[taskId].tButton = 0; gSprites[sDecor_CameraSpriteObjectIdx1].data[7] = 1; gSprites[sDecor_CameraSpriteObjectIdx2].data[7] = 1; - sub_8128DE0(); - AttemptPlaceDecoration(taskId); + ResetCursorMovement(); + AttemptPlaceDecoration_(taskId); } -void sub_8128414(u8 taskId) +static void AttemptCancelPlaceDecoration(u8 taskId) { - gTasks[taskId].data[10] = 0; + gTasks[taskId].tButton = 0; gSprites[sDecor_CameraSpriteObjectIdx1].data[7] = 1; gSprites[sDecor_CameraSpriteObjectIdx2].data[7] = 1; - sub_8128DE0(); + ResetCursorMovement(); StringExpandPlaceholders(gStringVar4, gText_CancelDecorating); DisplayItemMessageOnField(taskId, gStringVar4, CancelDecoratingPrompt); } -bool8 sub_8128484(u8 behaviorAt, u16 behaviorBy) +// Note: behaviorBy is pre-anded with METATILE_ELEVATION_MASK. +static bool8 IsNonBlockNonElevated(u8 behaviorAt, u16 behaviorBy) { if (MetatileBehavior_IsBlockDecoration(behaviorAt) != TRUE || behaviorBy != 0) - { return FALSE; - } return TRUE; } -bool8 sub_81284AC(u8 taskId, s16 x, s16 y, u16 decor) +static bool8 IsntInitialPosition(u8 taskId, s16 x, s16 y, u16 behaviorBy) { - if (x == gTasks[taskId].data[3] + 7 && y == gTasks[taskId].data[4] + 7 && decor != DECOR_NONE) - { + if (x == gTasks[taskId].tInitialX + 7 && y == gTasks[taskId].tInitialY + 7 && behaviorBy != 0) return FALSE; - } return TRUE; } -bool8 sub_81284F4(u16 behaviorAt, const struct Decoration *decoration) +static bool8 IsFloorOrBoardAndHole(u16 behaviorAt, const struct Decoration *decoration) { if (MetatileBehavior_IsBlockDecoration(behaviorAt) != TRUE) { @@ -1474,7 +1500,7 @@ bool8 sub_81284F4(u16 behaviorAt, const struct Decoration *decoration) return FALSE; } -bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration) +static bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration) { u8 i; u8 j; @@ -1484,8 +1510,8 @@ bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration) u8 mapX; s16 curY; s16 curX; - mapY = gTasks[taskId].data[6]; - mapX = gTasks[taskId].data[5]; + mapY = gTasks[taskId].tDecorHeight; + mapX = gTasks[taskId].tDecorWidth; switch (decoration->permission) { @@ -1493,16 +1519,16 @@ bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration) case DECORPERM_PASS_FLOOR: for (i = 0; i < mapY; i++) { - curY = gTasks[taskId].data[1] - i; + curY = gTasks[taskId].tCursorY - i; for (j = 0; j < mapX; j++) { - curX = gTasks[taskId].data[0] + j; + curX = gTasks[taskId].tCursorX + j; behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY); behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ELEVATION_MASK; - if (!sub_81284F4(behaviorAt, decoration)) + if (!IsFloorOrBoardAndHole(behaviorAt, decoration)) return FALSE; - if (!sub_81284AC(taskId, curX, curY, behaviorBy)) + if (!IsntInitialPosition(taskId, curX, curY, behaviorBy)) return FALSE; behaviorAt = GetObjectEventIdByXYZ(curX, curY, 0); @@ -1514,16 +1540,16 @@ bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration) case DECORPERM_BEHIND_FLOOR: for (i = 0; i < mapY - 1; i++) { - curY = gTasks[taskId].data[1] - i; + curY = gTasks[taskId].tCursorY - i; for (j = 0; j < mapX; j++) { - curX = gTasks[taskId].data[0] + j; + curX = gTasks[taskId].tCursorX + j; behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY); behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[(mapY - 1 - i) * mapX + j]) & METATILE_ELEVATION_MASK; - if (!MetatileBehavior_IsNormal(behaviorAt) && !sub_8128484(behaviorAt, behaviorBy)) + if (!MetatileBehavior_IsNormal(behaviorAt) && !IsNonBlockNonElevated(behaviorAt, behaviorBy)) return FALSE; - if (!sub_81284AC(taskId, curX, curY, behaviorBy)) + if (!IsntInitialPosition(taskId, curX, curY, behaviorBy)) return FALSE; if (GetObjectEventIdByXYZ(curX, curY, 0) != 16) @@ -1531,16 +1557,16 @@ bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration) } } - curY = gTasks[taskId].data[1] - mapY + 1; + curY = gTasks[taskId].tCursorY - mapY + 1; for (j = 0; j < mapX; j++) { - curX = gTasks[taskId].data[0] + j; + curX = gTasks[taskId].tCursorX + j; behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY); behaviorBy = GetBehaviorByMetatileId(0x200 + decoration->tiles[j]) & METATILE_ELEVATION_MASK; if (!MetatileBehavior_IsNormal(behaviorAt) && !MetatileBehavior_IsSecretBaseNorthWall(behaviorAt)) return FALSE; - if (!sub_81284AC(taskId, curX, curY, behaviorBy)) + if (!IsntInitialPosition(taskId, curX, curY, behaviorBy)) return FALSE; behaviorAt = GetObjectEventIdByXYZ(curX, curY, 0); @@ -1551,23 +1577,23 @@ bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration) case DECORPERM_NA_WALL: for (i = 0; i < mapY; i++) { - curY = gTasks[taskId].data[1] - i; + curY = gTasks[taskId].tCursorY - i; for (j = 0; j < mapX; j++) { - curX = gTasks[taskId].data[0] + j; + curX = gTasks[taskId].tCursorX + j; if (!MetatileBehavior_IsSecretBaseNorthWall(MapGridGetMetatileBehaviorAt(curX, curY))) return FALSE; - if (MapGridGetMetatileIdAt(curX, curY + 1) == 0x28c) + if (MapGridGetMetatileIdAt(curX, curY + 1) == METATILE_SecretBase_SandOrnament_BrokenBase) return FALSE; } } break; case DECORPERM_SPRITE: - curY = gTasks[taskId].data[1]; + curY = gTasks[taskId].tCursorY; for (j = 0; j < mapX; j++) { - curX = gTasks[taskId].data[0] + j; + curX = gTasks[taskId].tCursorX + j; behaviorAt = MapGridGetMetatileBehaviorAt(curX, curY); if (decoration->shape == DECORSHAPE_1x2) { @@ -1588,7 +1614,7 @@ bool8 CanPlaceDecoration(u8 taskId, const struct Decoration *decoration) return TRUE; } -void AttemptPlaceDecoration(u8 taskId) +static void AttemptPlaceDecoration_(u8 taskId) { if (CanPlaceDecoration(taskId, &gDecorations[gCurDecorationItems[gCurDecorationIndex]]) == TRUE) { @@ -1603,24 +1629,24 @@ void AttemptPlaceDecoration(u8 taskId) } } -void PlaceDecorationPrompt(u8 taskId) +static void PlaceDecorationPrompt(u8 taskId) { DisplayYesNoMenuDefaultYes(); DoYesNoFuncWithChoice(taskId, &sPlaceDecorationYesNoFunctions); } -void PlaceDecoration(u8 taskId) +static void PlaceDecoration(u8 taskId) { ClearDialogWindowAndFrame(0, 0); - sub_8128AAC(taskId); + PlaceDecoration_(taskId); if (gDecorations[gCurDecorationItems[gCurDecorationIndex]].permission != DECORPERM_SPRITE) { - ShowDecorationOnMap(gTasks[taskId].data[0], gTasks[taskId].data[1], gCurDecorationItems[gCurDecorationIndex]); + ShowDecorationOnMap(gTasks[taskId].tCursorX, gTasks[taskId].tCursorY, gCurDecorationItems[gCurDecorationIndex]); } else { - sCurDecorMapX = gTasks[taskId].data[0] - 7; - sCurDecorMapY = gTasks[taskId].data[1] - 7; + sCurDecorMapX = gTasks[taskId].tCursorX - 7; + sCurDecorMapY = gTasks[taskId].tCursorY - 7; ScriptContext1_SetupScript(SecretBase_EventScript_SetDecoration); } @@ -1628,28 +1654,28 @@ void PlaceDecoration(u8 taskId) if (gMapHeader.regionMapSectionId == MAPSEC_SECRET_BASE) TV_PutSecretBaseVisitOnTheAir(); - sub_8128BBC(taskId); + CancelDecorating_(taskId); } -void sub_8128AAC(u8 taskId) +static void PlaceDecoration_(u8 taskId) { u16 i; - for (i = 0; i < gDecorationContext.size; i++) + for (i = 0; i < sDecorationContext.size; i++) { - if (gDecorationContext.items[i] == DECOR_NONE) + if (sDecorationContext.items[i] == DECOR_NONE) { - gDecorationContext.items[i] = gCurDecorationItems[gCurDecorationIndex]; - gDecorationContext.pos[i] = ((gTasks[taskId].data[0] - 7) << 4) + (gTasks[taskId].data[1] - 7); + sDecorationContext.items[i] = gCurDecorationItems[gCurDecorationIndex]; + sDecorationContext.pos[i] = ((gTasks[taskId].tCursorX - 7) << 4) + (gTasks[taskId].tCursorY - 7); break; } } - if (!gDecorationContext.isPlayerRoom) + if (!sDecorationContext.isPlayerRoom) { for (i = 0; i < DECOR_MAX_SECRET_BASE; i++) { - if (sSecretBaseItemsIndicesBuffer[i] == 0) + if (sSecretBaseItemsIndicesBuffer[i] == DECOR_NONE) { sSecretBaseItemsIndicesBuffer[i] = gCurDecorationIndex + 1; break; @@ -1660,7 +1686,7 @@ void sub_8128AAC(u8 taskId) { for (i = 0; i < DECOR_MAX_PLAYERS_HOUSE; i++) { - if (sPlayerRoomItemsIndicesBuffer[i] == 0) + if (sPlayerRoomItemsIndicesBuffer[i] == DECOR_NONE) { sPlayerRoomItemsIndicesBuffer[i] = gCurDecorationIndex + 1; break; @@ -1669,63 +1695,63 @@ void sub_8128AAC(u8 taskId) } } -void CancelDecoratingPrompt(u8 taskId) +static void CancelDecoratingPrompt(u8 taskId) { DisplayYesNoMenuDefaultYes(); DoYesNoFuncWithChoice(taskId, &sCancelDecoratingYesNoFunctions); } -void CancelDecorating(u8 taskId) +static void CancelDecorating(u8 taskId) { ClearDialogWindowAndFrame(0, 0); - sub_8128BBC(taskId); + CancelDecorating_(taskId); } -void sub_8128BBC(u8 taskId) +static void CancelDecorating_(u8 taskId) { FadeScreen(FADE_TO_BLACK, 0); - gTasks[taskId].data[2] = 0; + gTasks[taskId].tState = 0; gTasks[taskId].func = c1_overworld_prev_quest; } -void c1_overworld_prev_quest(u8 taskId) +static void c1_overworld_prev_quest(u8 taskId) { - switch (gTasks[taskId].data[2]) + switch (gTasks[taskId].tState) { case 0: ScriptContext2_Enable(); if (!gPaletteFade.active) { - sub_8127B04(taskId); - gTasks[taskId].data[2] = 1; + WarpToInitialPosition(taskId); + gTasks[taskId].tState = 1; } break; case 1: - sub_812A3C8(); + FreePlayerSpritePalette(); FreeSpritePaletteByTag(PLACE_DECORATION_SELECTOR_TAG); - gFieldCallback = sub_8128CD4; + gFieldCallback = FieldCB_InitDecorationItemsWindow; SetMainCallback2(CB2_ReturnToField); DestroyTask(taskId); break; } } -void sub_8128C64(u8 taskId) +static void Task_InitDecorationItemsWindow(u8 taskId) { s16 *data = gTasks[taskId].data; - switch (data[2]) + switch (tState) { case 0: HideSecretBaseDecorationSprites(); - data[2]++; + tState++; break; case 1: ScriptContext1_SetupScript(SecretBase_EventScript_InitDecorations); - data[2]++; + tState++; break; case 2: ScriptContext2_Enable(); - data[2]++; + tState++; break; case 3: if (IsWeatherNotFadingIn() == TRUE) @@ -1734,48 +1760,48 @@ void sub_8128C64(u8 taskId) } } -void sub_8128CD4(void) +static void FieldCB_InitDecorationItemsWindow(void) { u8 taskId; ScriptContext2_Enable(); FadeInFromBlack(); - taskId = CreateTask(sub_8128C64, 8); - sub_8127580(taskId); - gTasks[taskId].data[2] = 0; + taskId = CreateTask(Task_InitDecorationItemsWindow, 8); + AddDecorationItemsWindow(taskId); + gTasks[taskId].tState = 0; } -bool8 sub_8128D10(u8 taskId) +static bool8 ApplyCursorMovement_IsInvalid(u8 taskId) { s16 *data = gTasks[taskId].data; - if (sDecorationLastDirectionMoved == DIR_SOUTH && data[1] - data[6] - 6 < 0) + if (sDecorationLastDirectionMoved == DIR_SOUTH && tCursorY - tDecorHeight - 6 < 0) { - data[1]++; + tCursorY++; return FALSE; } - if (sDecorationLastDirectionMoved == DIR_NORTH && data[1] - 7 >= gMapHeader.mapLayout->height) + if (sDecorationLastDirectionMoved == DIR_NORTH && tCursorY - 7 >= gMapHeader.mapLayout->height) { - data[1]--; + tCursorY--; return FALSE; } - if (sDecorationLastDirectionMoved == DIR_WEST && data[0] - 7 < 0) + if (sDecorationLastDirectionMoved == DIR_WEST && tCursorX - 7 < 0) { - data[0]++; + tCursorX++; return FALSE; } - if (sDecorationLastDirectionMoved == DIR_EAST && data[0] + data[5] - 8 >= gMapHeader.mapLayout->width) + if (sDecorationLastDirectionMoved == DIR_EAST && tCursorX + tDecorWidth - 8 >= gMapHeader.mapLayout->width) { - data[0]--; + tCursorX--; return FALSE; } return TRUE; } -bool8 sub_8128DB4(void) +static bool8 IsHoldingDirection(void) { u16 heldKeys = gMain.heldKeys & DPAD_ANY; if (heldKeys != DPAD_UP && heldKeys != DPAD_DOWN && heldKeys != DPAD_LEFT && heldKeys != DPAD_RIGHT) @@ -1784,26 +1810,26 @@ bool8 sub_8128DB4(void) return TRUE; } -void sub_8128DE0(void) +static void ResetCursorMovement(void) { sDecorationLastDirectionMoved = 0; gSprites[sDecor_CameraSpriteObjectIdx1].data[2] = 0; gSprites[sDecor_CameraSpriteObjectIdx1].data[3] = 0; } -void sub_8128E18(u8 taskId) +static void Task_SelectLocation(u8 taskId) { s16 *data = gTasks[taskId].data; if (!gSprites[sDecor_CameraSpriteObjectIdx1].data[4]) { - if (data[10] == 1) + if (tButton == A_BUTTON) { - gUnknown_085A72D4[data[12]].yesFunc(taskId); + sPlacePutAwayYesNoFunctions[tDecorationItemsMenuCommand].yesFunc(taskId); return; } - else if (data[10] == 2) + else if (tButton == B_BUTTON) { - gUnknown_085A72D4[data[12]].noFunc(taskId); + sPlacePutAwayYesNoFunctions[tDecorationItemsMenuCommand].noFunc(taskId); return; } @@ -1812,7 +1838,7 @@ void sub_8128E18(u8 taskId) sDecorationLastDirectionMoved = DIR_SOUTH; gSprites[sDecor_CameraSpriteObjectIdx1].data[2] = 0; gSprites[sDecor_CameraSpriteObjectIdx1].data[3] = -2; - data[1]--; + tCursorY--; } if ((gMain.heldKeys & DPAD_ANY) == DPAD_DOWN) @@ -1820,7 +1846,7 @@ void sub_8128E18(u8 taskId) sDecorationLastDirectionMoved = DIR_NORTH; gSprites[sDecor_CameraSpriteObjectIdx1].data[2] = 0; gSprites[sDecor_CameraSpriteObjectIdx1].data[3] = 2; - data[1]++; + tCursorY++; } if ((gMain.heldKeys & DPAD_ANY) == DPAD_LEFT) @@ -1828,7 +1854,7 @@ void sub_8128E18(u8 taskId) sDecorationLastDirectionMoved = DIR_WEST; gSprites[sDecor_CameraSpriteObjectIdx1].data[2] = -2; gSprites[sDecor_CameraSpriteObjectIdx1].data[3] = 0; - data[0]--; + tCursorX--; } if ((gMain.heldKeys & DPAD_ANY) == DPAD_RIGHT) @@ -1836,11 +1862,11 @@ void sub_8128E18(u8 taskId) sDecorationLastDirectionMoved = DIR_EAST; gSprites[sDecor_CameraSpriteObjectIdx1].data[2] = 2; gSprites[sDecor_CameraSpriteObjectIdx1].data[3] = 0; - data[0]++; + tCursorX++; } - if (!sub_8128DB4() || !sub_8128D10(taskId)) - sub_8128DE0(); + if (!IsHoldingDirection() || !ApplyCursorMovement_IsInvalid(taskId)) + ResetCursorMovement(); } if (sDecorationLastDirectionMoved) @@ -1849,43 +1875,43 @@ void sub_8128E18(u8 taskId) gSprites[sDecor_CameraSpriteObjectIdx1].data[4] &= 7; } - if (!data[10]) + if (!tButton) { if (gMain.newKeys & A_BUTTON) - data[10] = A_BUTTON; + tButton = A_BUTTON; if (gMain.newKeys & B_BUTTON) - data[10] = B_BUTTON; + tButton = B_BUTTON; } } -void ContinueDecorating(u8 taskId) +static void ContinueDecorating(u8 taskId) { ClearDialogWindowAndFrame(0, 1); gSprites[sDecor_CameraSpriteObjectIdx1].data[7] = 0; - gTasks[taskId].data[10] = 0; - gTasks[taskId].func = sub_8128E18; + gTasks[taskId].tButton = 0; + gTasks[taskId].func = Task_SelectLocation; } -void CantPlaceDecorationPrompt(u8 taskId) +static void CantPlaceDecorationPrompt(u8 taskId) { if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) ContinueDecorating(taskId); } -void sub_8129048(struct PlaceDecorationGraphicsDataBuffer *data) +static void ClearPlaceDecorationGraphicsDataBuffer(struct PlaceDecorationGraphicsDataBuffer *data) { CpuFill16(0, data, sizeof(*data)); } -void sub_8129068(u16 *dest, u16 pal) +static void CopyPalette(u16 *dest, u16 pal) { - CpuFastCopy(&((u16 *)gTilesetPointer_SecretBase->palettes)[pal << 4], dest, 32); + CpuFastCopy(&((u16 *)gTilesetPointer_SecretBase->palettes)[pal * 16], dest, sizeof(u16) * 16); } -void sub_8129088(u8 *dest, u16 tile) +static void CopyTile(u8 *dest, u16 tile) { - u8 buffer[32]; + u8 buffer[TILE_SIZE_4BPP]; u16 mode; u16 i; @@ -1893,13 +1919,13 @@ void sub_8129088(u8 *dest, u16 tile) if (tile != 0) tile &= 0x03FF; - CpuFastCopy(&((u8 *)gTilesetPointer_SecretBase->tiles)[tile << 5], buffer, 32); + CpuFastCopy(&((u8 *)gTilesetPointer_SecretBase->tiles)[tile * TILE_SIZE_4BPP], buffer, TILE_SIZE_4BPP); switch (mode) { case 0: - CpuFastCopy(buffer, dest, 32); + CpuFastCopy(buffer, dest, TILE_SIZE_4BPP); break; - case 1: + case BG_TILE_H_FLIP(0) >> 10: for (i = 0; i < 8; i++) { dest[4 * i] = (buffer[4 * (i + 1) - 1] >> 4) + ((buffer[4 * (i + 1) - 1] & 0x0F) << 4); @@ -1908,7 +1934,7 @@ void sub_8129088(u8 *dest, u16 tile) dest[4 * i + 3] = (buffer[4 * (i + 1) - 4] >> 4) + ((buffer[4 * (i + 1) - 4] & 0x0F) << 4); } break; - case 2: + case BG_TILE_V_FLIP(0) >> 10: for (i = 0; i < 8; i++) { dest[4 * i] = buffer[4 * (7 - i)]; @@ -1917,7 +1943,7 @@ void sub_8129088(u8 *dest, u16 tile) dest[4 * i + 3] = buffer[4 * (7 - i) + 3]; } break; - case 3: + case BG_TILE_H_FLIP(BG_TILE_V_FLIP(0)) >> 10: for (i = 0; i < 32; i++) { dest[i] = (buffer[31 - i] >> 4) + ((buffer[31 - i] & 0x0F) << 4); @@ -1926,19 +1952,19 @@ void sub_8129088(u8 *dest, u16 tile) } } -void sub_81291A4(struct PlaceDecorationGraphicsDataBuffer *data) +static void SetDecorSelectionBoxTiles(struct PlaceDecorationGraphicsDataBuffer *data) { u16 i; for (i = 0; i < 64; i++) - sub_8129088(&data->image[i * 32], data->tiles[i]); + CopyTile(&data->image[i * TILE_SIZE_4BPP], data->tiles[i]); } -u16 sub_81291CC(u16 tile) +static u16 GetMetatile(u16 tile) { return ((u16 *)gTilesetPointer_SecretBaseRedCave->metatiles)[tile] & 0xFFF; } -void sub_81291E8(struct PlaceDecorationGraphicsDataBuffer *data) +static void SetDecorSelectionMetatiles(struct PlaceDecorationGraphicsDataBuffer *data) { u8 i; u8 shape; @@ -1946,11 +1972,11 @@ void sub_81291E8(struct PlaceDecorationGraphicsDataBuffer *data) shape = data->decoration->shape; for (i = 0; i < gUnknown_085A71B0[shape].size; i++) { - data->tiles[gUnknown_085A71B0[shape].tiles[i]] = sub_81291CC(data->decoration->tiles[gUnknown_085A71B0[shape].y[i]] * 8 + gUnknown_085A71B0[shape].x[i]); + data->tiles[gUnknown_085A71B0[shape].tiles[i]] = GetMetatile(data->decoration->tiles[gUnknown_085A71B0[shape].y[i]] * 8 + gUnknown_085A71B0[shape].x[i]); } } -void SetDecorSelectionBoxOamAttributes(u8 decorShape) +static void SetDecorSelectionBoxOamAttributes(u8 decorShape) { sDecorSelectorOam.y = 0; sDecorSelectorOam.affineMode = ST_OAM_AFFINE_OFF; @@ -1966,7 +1992,7 @@ void SetDecorSelectionBoxOamAttributes(u8 decorShape) sDecorSelectorOam.paletteNum = 0; } -void sub_81292D0(struct Sprite *sprite) +static void InitializePuttingAwayCursorSprite(struct Sprite *sprite) { sprite->data[2] = 0; sprite->data[3] = 0; @@ -1974,10 +2000,10 @@ void sub_81292D0(struct Sprite *sprite) sprite->data[5] = 0; sprite->data[6] = 0; sprite->data[7] = 0; - sprite->callback = sub_81292E8; + sprite->callback = InitializePuttingAwayCursorSprite2; } -void sub_81292E8(struct Sprite *sprite) +static void InitializePuttingAwayCursorSprite2(struct Sprite *sprite) { if (sprite->data[7] == 0) { @@ -1995,23 +2021,23 @@ void sub_81292E8(struct Sprite *sprite) } } -u8 gpu_pal_decompress_alloc_tag_and_upload(struct PlaceDecorationGraphicsDataBuffer *data, u8 decor) +static u8 gpu_pal_decompress_alloc_tag_and_upload(struct PlaceDecorationGraphicsDataBuffer *data, u8 decor) { - sub_8129048(data); + ClearPlaceDecorationGraphicsDataBuffer(data); data->decoration = &gDecorations[decor]; if (data->decoration->permission == DECORPERM_SPRITE) return AddPseudoObjectEvent(data->decoration->tiles[0], SpriteCallbackDummy, 0, 0, 1); FreeSpritePaletteByTag(PLACE_DECORATION_SELECTOR_TAG); - sub_81291E8(data); + SetDecorSelectionMetatiles(data); SetDecorSelectionBoxOamAttributes(data->decoration->shape); - sub_81291A4(data); - sub_8129068(data->palette, ((u16 *)gTilesetPointer_SecretBaseRedCave->metatiles)[(data->decoration->tiles[0] * 8) + 7] >> 12); - LoadSpritePalette(&gUnknown_085A72BC); + SetDecorSelectionBoxTiles(data); + CopyPalette(data->palette, ((u16 *)gTilesetPointer_SecretBaseRedCave->metatiles)[(data->decoration->tiles[0] * 8) + 7] >> 12); + LoadSpritePalette(&sSpritePal_PlaceDecoration); return CreateSprite(&sDecorationSelectorSpriteTemplate, 0, 0, 0); } -u8 AddDecorationIconObjectFromIconTable(u16 tilesTag, u16 paletteTag, u8 decor) +static u8 AddDecorationIconObjectFromIconTable(u16 tilesTag, u16 paletteTag, u8 decor) { struct SpriteSheet sheet; struct CompressedSpritePalette palette; @@ -2040,7 +2066,7 @@ u8 AddDecorationIconObjectFromIconTable(u16 tilesTag, u16 paletteTag, u8 decor) return spriteId; } -const u32 *GetDecorationIconPicOrPalette(u16 decor, u8 mode) +static const u32 *GetDecorationIconPicOrPalette(u16 decor, u8 mode) { if (decor > NUM_DECORATIONS) decor = DECOR_NONE; @@ -2048,23 +2074,23 @@ const u32 *GetDecorationIconPicOrPalette(u16 decor, u8 mode) return gDecorIconTable[decor][mode]; } -u8 AddDecorationIconObjectFromObjectEvent(u16 tilesTag, u16 paletteTag, u8 decor) +static u8 AddDecorationIconObjectFromObjectEvent(u16 tilesTag, u16 paletteTag, u8 decor) { u8 spriteId; struct SpriteSheet sheet; struct SpritePalette palette; struct SpriteTemplate *template; - sub_8129048(&sPlaceDecorationGraphicsDataBuffer); + ClearPlaceDecorationGraphicsDataBuffer(&sPlaceDecorationGraphicsDataBuffer); sPlaceDecorationGraphicsDataBuffer.decoration = &gDecorations[decor]; if (sPlaceDecorationGraphicsDataBuffer.decoration->permission != DECORPERM_SPRITE) { - sub_81291E8(&sPlaceDecorationGraphicsDataBuffer); + SetDecorSelectionMetatiles(&sPlaceDecorationGraphicsDataBuffer); SetDecorSelectionBoxOamAttributes(sPlaceDecorationGraphicsDataBuffer.decoration->shape); - sub_81291A4(&sPlaceDecorationGraphicsDataBuffer); - sub_8129068(sPlaceDecorationGraphicsDataBuffer.palette, ((u16 *)gTilesetPointer_SecretBaseRedCave->metatiles)[(sPlaceDecorationGraphicsDataBuffer.decoration->tiles[0] * 8) + 7] >> 12); + SetDecorSelectionBoxTiles(&sPlaceDecorationGraphicsDataBuffer); + CopyPalette(sPlaceDecorationGraphicsDataBuffer.palette, ((u16 *)gTilesetPointer_SecretBaseRedCave->metatiles)[(sPlaceDecorationGraphicsDataBuffer.decoration->tiles[0] * 8) + 7] >> 12); sheet.data = sPlaceDecorationGraphicsDataBuffer.image; - sheet.size = gUnknown_085A72F4[sPlaceDecorationGraphicsDataBuffer.decoration->shape] << 5; + sheet.size = sDecorShapeSizes[sPlaceDecorationGraphicsDataBuffer.decoration->shape] * TILE_SIZE_4BPP; sheet.tag = tilesTag; LoadSpriteSheet(&sheet); palette.data = sPlaceDecorationGraphicsDataBuffer.palette; @@ -2123,26 +2149,33 @@ u8 AddDecorationIconObject(u8 decor, s16 x, s16 y, u8 priority, u16 tilesTag, u1 return spriteId; } -void sub_81296EC(u8 idx) +static void ClearDecorationContextIndex(u8 idx) { - gDecorationContext.items[idx] = 0; - gDecorationContext.pos[idx] = 0; + sDecorationContext.items[idx] = DECOR_NONE; + sDecorationContext.pos[idx] = 0; } -void sub_8129708(void) +// Input +// gSpecialVar_0x8004: Current iteration. +// +// Output +// gSpecialVar_Result: TRUE if all iterations complete. +// gSpecialVar_0x8005: flagId of decoration (if any). +// gSpecialVar_0x8006: localId of decoration object event (if any). +void PutAwayDecorationIteration(void) { u16 i; gSpecialVar_0x8005 = 0; - gSpecialVar_Result = 0; + gSpecialVar_Result = FALSE; if (gSpecialVar_0x8004 == sCurDecorSelectedInRearrangement) { - gSpecialVar_Result = 1; + gSpecialVar_Result = TRUE; } - else if (gDecorations[gDecorationContext.items[sDecorRearrangementDataBuffer[gSpecialVar_0x8004].idx]].permission == DECORPERM_SPRITE) + else if (gDecorations[sDecorationContext.items[sDecorRearrangementDataBuffer[gSpecialVar_0x8004].idx]].permission == DECORPERM_SPRITE) { gSpecialVar_0x8005 = sDecorRearrangementDataBuffer[gSpecialVar_0x8004].flagId; - sub_81296EC(sDecorRearrangementDataBuffer[gSpecialVar_0x8004].idx); + ClearDecorationContextIndex(sDecorRearrangementDataBuffer[gSpecialVar_0x8004].idx); for (i = 0; i < gMapHeader.events->objectEventCount; i++) { if (gMapHeader.events->objectEvents[i].flagId == gSpecialVar_0x8005) @@ -2169,7 +2202,7 @@ void GetObjectEventLocalIdByFlag(void) } } -void sub_81297F8(void) +static void ClearRearrangementNonSprites(void) { u8 i; u8 y; @@ -2180,9 +2213,9 @@ void sub_81297F8(void) for (i = 0; i < sCurDecorSelectedInRearrangement; i++) { - perm = gDecorations[gDecorationContext.items[sDecorRearrangementDataBuffer[i].idx]].permission; - posX = gDecorationContext.pos[sDecorRearrangementDataBuffer[i].idx] >> 4; - posY = gDecorationContext.pos[sDecorRearrangementDataBuffer[i].idx] & 0x0F; + perm = gDecorations[sDecorationContext.items[sDecorRearrangementDataBuffer[i].idx]].permission; + posX = sDecorationContext.pos[sDecorRearrangementDataBuffer[i].idx] >> 4; + posY = sDecorationContext.pos[sDecorRearrangementDataBuffer[i].idx] & 0x0F; if (perm != DECORPERM_SPRITE) { for (y = 0; y < sDecorRearrangementDataBuffer[i].height; y++) @@ -2193,32 +2226,32 @@ void sub_81297F8(void) } } - sub_81296EC(sDecorRearrangementDataBuffer[i].idx); + ClearDecorationContextIndex(sDecorRearrangementDataBuffer[i].idx); } } } -void sub_81298EC(u8 taskId) +static void Task_PutAwayDecoration(u8 taskId) { - switch (gTasks[taskId].data[2]) + switch (gTasks[taskId].tState) { case 0: - sub_81297F8(); - gTasks[taskId].data[2] = 1; + ClearRearrangementNonSprites(); + gTasks[taskId].tState = 1; break; case 1: if (!gPaletteFade.active) { DrawWholeMapView(); ScriptContext1_SetupScript(SecretBase_EventScript_PutAwayDecoration); ClearDialogWindowAndFrame(0, 1); - gTasks[taskId].data[2] = 2; + gTasks[taskId].tState = 2; } break; case 2: ScriptContext2_Enable(); IdentifyOwnedDecorationsCurrentlyInUseInternal(taskId); FadeInFromBlack(); - gTasks[taskId].data[2] = 3; + gTasks[taskId].tState = 3; break; case 3: if (IsWeatherNotFadingIn() == TRUE) @@ -2232,25 +2265,24 @@ void sub_81298EC(u8 taskId) } } - -bool8 sub_81299AC(u8 taskId) +static bool8 HasDecorationsInUse(u8 taskId) { u16 i; - for (i = 0; i < gDecorationContext.size; i++) + for (i = 0; i < sDecorationContext.size; i++) { - if (gDecorationContext.items[i] != DECOR_NONE) + if (sDecorationContext.items[i] != DECOR_NONE) return TRUE; } return FALSE; } -void SetUpPuttingAwayDecorationPlayerAvatar(void) +static void SetUpPuttingAwayDecorationPlayerAvatar(void) { GetPlayerFacingDirection(); sDecor_CameraSpriteObjectIdx1 = gSprites[gFieldCamera.spriteId].data[0]; - sub_812A39C(); - gFieldCamera.spriteId = CreateSprite(&gUnknown_085A7404, 120, 80, 0); + LoadPlayerSpritePalette(); + gFieldCamera.spriteId = CreateSprite(&sPuttingAwayCursorSpriteTemplate, 120, 80, 0); if (gSaveBlock2Ptr->playerGender == MALE) sDecor_CameraSpriteObjectIdx2 = AddPseudoObjectEvent(OBJ_EVENT_GFX_BRENDAN_DECORATING, SpriteCallbackDummy, 136, 72, 0); else @@ -2262,72 +2294,72 @@ void SetUpPuttingAwayDecorationPlayerAvatar(void) gSprites[sDecor_CameraSpriteObjectIdx1].oam.priority = 1; } -void sub_8129ABC(u8 taskId) +static void Task_ContinuePuttingAwayDecorations(u8 taskId) { s16 *data; data = gTasks[taskId].data; - switch (data[2]) + switch (tState) { case 0: if (!gPaletteFade.active) { - sub_8127ACC(taskId); - data[2] = 1; - data[6] = 1; - data[5] = 1; + SetInitialPositions(taskId); + tState = 1; + tDecorHeight = 1; + tDecorWidth = 1; } break; case 1: SetUpPuttingAwayDecorationPlayerAvatar(); FadeInFromBlack(); - data[2] = 2; + tState = 2; break; case 2: if (IsWeatherNotFadingIn() == TRUE) { - data[12] = 1; + tDecorationItemsMenuCommand = DECOR_ITEMS_MENU_PUT_AWAY; ContinuePuttingAwayDecorations(taskId); } break; } } -void ContinuePuttingAwayDecorations(u8 taskId) +static void ContinuePuttingAwayDecorations(u8 taskId) { ClearDialogWindowAndFrame(0, 1); gSprites[sDecor_CameraSpriteObjectIdx1].data[7] = 0; gSprites[sDecor_CameraSpriteObjectIdx1].invisible = FALSE; - gSprites[sDecor_CameraSpriteObjectIdx1].callback = sub_812A36C; + gSprites[sDecor_CameraSpriteObjectIdx1].callback = InitializeCameraSprite1; gSprites[sDecor_CameraSpriteObjectIdx2].pos1.x = 136; gSprites[sDecor_CameraSpriteObjectIdx2].pos1.y = 72; - gTasks[taskId].data[10] = 0; - gTasks[taskId].func = sub_8128E18; + gTasks[taskId].tButton = 0; + gTasks[taskId].func = Task_SelectLocation; } -void sub_8129BCC(u8 taskId) +static void AttemptPutAwayDecoration(u8 taskId) { - gTasks[taskId].data[10] = 0; - sub_8128DE0(); - sub_8129C74(taskId); + gTasks[taskId].tButton = 0; + ResetCursorMovement(); + AttemptPutAwayDecoration_(taskId); } -void sub_8129BF8(u8 taskId) +static void AttemptCancelPutAwayDecoration(u8 taskId) { - gTasks[taskId].data[10] = 0; - sub_8128DE0(); + gTasks[taskId].tButton = 0; + ResetCursorMovement(); gSprites[sDecor_CameraSpriteObjectIdx1].invisible = FALSE; gSprites[sDecor_CameraSpriteObjectIdx1].callback = SpriteCallbackDummy; StringExpandPlaceholders(gStringVar4, gText_StopPuttingAwayDecorations); DisplayItemMessageOnField(taskId, gStringVar4, StopPuttingAwayDecorationsPrompt); } -void sub_8129C74(u8 taskId) +static void AttemptPutAwayDecoration_(u8 taskId) { s16 *data; u8 behavior; - sub_812A0E8(taskId); + AttemptMarkDecorUnderCursorForRemoval(taskId); if (sCurDecorSelectedInRearrangement != 0) { StringExpandPlaceholders(gStringVar4, gText_ReturnDecorationToPC); @@ -2336,7 +2368,7 @@ void sub_8129C74(u8 taskId) else { data = gTasks[taskId].data; - behavior = MapGridGetMetatileBehaviorAt(data[0], data[1]); + behavior = MapGridGetMetatileBehaviorAt(tCursorX, tCursorY); if (MetatileBehavior_IsSecretBasePC(behavior) == TRUE || MetatileBehavior_IsPlayerRoomPCOn(behavior) == TRUE) { gSprites[sDecor_CameraSpriteObjectIdx1].invisible = FALSE; @@ -2352,13 +2384,13 @@ void sub_8129C74(u8 taskId) } } -void ContinuePuttingAwayDecorationsPrompt(u8 taskId) +static void ContinuePuttingAwayDecorationsPrompt(u8 taskId) { if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) ContinuePuttingAwayDecorations(taskId); } -void sub_8129D8C(u8 decor, struct DecorRearrangementDataBuffer *data) +static void SetDecorRearrangementShape(u8 decor, struct DecorRearrangementDataBuffer *data) { if (gDecorations[decor].shape == DECORSHAPE_1x1) { @@ -2412,15 +2444,15 @@ void sub_8129D8C(u8 decor, struct DecorRearrangementDataBuffer *data) } } -void sub_8129E0C(u8 x, u8 y) +static void SetCameraSpritePosition(u8 x, u8 y) { gSprites[sDecor_CameraSpriteObjectIdx1].invisible = TRUE; gSprites[sDecor_CameraSpriteObjectIdx1].callback = SpriteCallbackDummy; - gSprites[sDecor_CameraSpriteObjectIdx2].pos1.x = (x << 4) + 136; - gSprites[sDecor_CameraSpriteObjectIdx2].pos1.y = (y << 4) + 72; + gSprites[sDecor_CameraSpriteObjectIdx2].pos1.x = x * 16 + 136; + gSprites[sDecor_CameraSpriteObjectIdx2].pos1.y = y * 16 + 72; } -bool8 sub_8129E74(u8 taskId, u8 idx, struct DecorRearrangementDataBuffer *data) +static bool8 DecorationIsUnderCursor(u8 taskId, u8 idx, struct DecorRearrangementDataBuffer *data) { u8 x; u8 y; @@ -2428,32 +2460,32 @@ bool8 sub_8129E74(u8 taskId, u8 idx, struct DecorRearrangementDataBuffer *data) u8 yOff; u8 ht; - x = gTasks[taskId].data[0] - 7; - y = gTasks[taskId].data[1] - 7; - xOff = gDecorationContext.pos[idx] >> 4; - yOff = gDecorationContext.pos[idx] & 0x0F; + x = gTasks[taskId].tCursorX - 7; + y = gTasks[taskId].tCursorY - 7; + xOff = sDecorationContext.pos[idx] >> 4; + yOff = sDecorationContext.pos[idx] & 0x0F; ht = data->height; - if (gDecorationContext.items[idx] == DECOR_SAND_ORNAMENT && MapGridGetMetatileIdAt(xOff + 7, yOff + 7) == 0x28C) + if (sDecorationContext.items[idx] == DECOR_SAND_ORNAMENT && MapGridGetMetatileIdAt(xOff + 7, yOff + 7) == METATILE_SecretBase_SandOrnament_BrokenBase) ht--; if (x >= xOff && x < xOff + data->width && y > yOff - ht && y <= yOff) { - sub_8129E0C(data->width - (x - xOff + 1), yOff - y); + SetCameraSpritePosition(data->width - (x - xOff + 1), yOff - y); return TRUE; } return FALSE; } -void sub_8129F20(void) +static void SetDecorRearrangementFlagIdIfFlagUnset(void) { u8 xOff; u8 yOff; u16 i; - xOff = gDecorationContext.pos[sDecorRearrangementDataBuffer[sCurDecorSelectedInRearrangement].idx] >> 4; - yOff = gDecorationContext.pos[sDecorRearrangementDataBuffer[sCurDecorSelectedInRearrangement].idx] & 0x0F; - for (i = 0; i < 0x40; i++) + xOff = sDecorationContext.pos[sDecorRearrangementDataBuffer[sCurDecorSelectedInRearrangement].idx] >> 4; + yOff = sDecorationContext.pos[sDecorRearrangementDataBuffer[sCurDecorSelectedInRearrangement].idx] & 0x0F; + for (i = 0; i < OBJECT_EVENT_TEMPLATES_COUNT; i++) { if (gSaveBlock1Ptr->objectEventTemplates[i].x == xOff && gSaveBlock1Ptr->objectEventTemplates[i].y == yOff && !FlagGet(gSaveBlock1Ptr->objectEventTemplates[i].flagId)) { @@ -2463,21 +2495,21 @@ void sub_8129F20(void) } } -bool8 sub_8129FC8(u8 taskId) +static bool8 AttemptMarkSpriteDecorUnderCursorForRemoval(u8 taskId) { u16 i; - for (i = 0; i < gDecorationContext.size; i++) + for (i = 0; i < sDecorationContext.size; i++) { - if (gDecorationContext.items[i] != 0) + if (sDecorationContext.items[i] != DECOR_NONE) { - if (gDecorations[gDecorationContext.items[i]].permission == DECORPERM_SPRITE) + if (gDecorations[sDecorationContext.items[i]].permission == DECORPERM_SPRITE) { - sub_8129D8C(gDecorationContext.items[i], sDecorRearrangementDataBuffer); - if (sub_8129E74(taskId, i, sDecorRearrangementDataBuffer) == TRUE) + SetDecorRearrangementShape(sDecorationContext.items[i], sDecorRearrangementDataBuffer); + if (DecorationIsUnderCursor(taskId, i, sDecorRearrangementDataBuffer) == TRUE) { sDecorRearrangementDataBuffer->idx = i; - sub_8129F20(); + SetDecorRearrangementFlagIdIfFlagUnset(); sCurDecorSelectedInRearrangement = 1; return TRUE; } @@ -2487,28 +2519,28 @@ bool8 sub_8129FC8(u8 taskId) return FALSE; } -void sub_812A040(u8 left, u8 top, u8 right, u8 bottom) +static void MarkSpriteDecorsInBoundsForRemoval(u8 left, u8 top, u8 right, u8 bottom) { u8 i; u8 xOff; u8 yOff; - u8 decorIdx; + u8 decor; - for (i = 0; i < gDecorationContext.size; i++) + for (i = 0; i < sDecorationContext.size; i++) { - decorIdx = gDecorationContext.items[i]; - xOff = gDecorationContext.pos[i] >> 4; - yOff = gDecorationContext.pos[i] & 0x0F; - if (decorIdx != 0 && gDecorations[decorIdx].permission == DECORPERM_SPRITE && left <= xOff && top <= yOff && right >= xOff && bottom >= yOff) + decor = sDecorationContext.items[i]; + xOff = sDecorationContext.pos[i] >> 4; + yOff = sDecorationContext.pos[i] & 0x0F; + if (decor != DECOR_NONE && gDecorations[decor].permission == DECORPERM_SPRITE && left <= xOff && top <= yOff && right >= xOff && bottom >= yOff) { sDecorRearrangementDataBuffer[sCurDecorSelectedInRearrangement].idx = i; - sub_8129F20(); + SetDecorRearrangementFlagIdIfFlagUnset(); sCurDecorSelectedInRearrangement++; } } } -void sub_812A0E8(u8 taskId) +static void AttemptMarkDecorUnderCursorForRemoval(u8 taskId) { u8 i; u8 xOff; @@ -2517,15 +2549,16 @@ void sub_812A0E8(u8 taskId) u32 var2; sCurDecorSelectedInRearrangement = 0; - if (sub_8129FC8(taskId) != TRUE) + if (AttemptMarkSpriteDecorUnderCursorForRemoval(taskId) != TRUE) { - for (i = 0; i < gDecorationContext.size; i++) + // Not a sprite. + for (i = 0; i < sDecorationContext.size; i++) { - var1 = gDecorationContext.items[i]; + var1 = sDecorationContext.items[i]; if (var1 != DECOR_NONE) { - sub_8129D8C(var1, &sDecorRearrangementDataBuffer[0]); - if (sub_8129E74(taskId, i, &sDecorRearrangementDataBuffer[0]) == TRUE) + SetDecorRearrangementShape(var1, &sDecorRearrangementDataBuffer[0]); + if (DecorationIsUnderCursor(taskId, i, &sDecorRearrangementDataBuffer[0]) == TRUE) { sDecorRearrangementDataBuffer[0].idx = i; sCurDecorSelectedInRearrangement++; @@ -2535,84 +2568,85 @@ void sub_812A0E8(u8 taskId) } if (sCurDecorSelectedInRearrangement != 0) { - xOff = gDecorationContext.pos[sDecorRearrangementDataBuffer[0].idx] >> 4; - yOff = gDecorationContext.pos[sDecorRearrangementDataBuffer[0].idx] & 0x0F; + xOff = sDecorationContext.pos[sDecorRearrangementDataBuffer[0].idx] >> 4; + yOff = sDecorationContext.pos[sDecorRearrangementDataBuffer[0].idx] & 0x0F; var1 = yOff - sDecorRearrangementDataBuffer[0].height + 1; var2 = sDecorRearrangementDataBuffer[0].width + xOff - 1; - sub_812A040(xOff, var1, var2, yOff); + // Remove any dolls/cushions on this decoration. + MarkSpriteDecorsInBoundsForRemoval(xOff, var1, var2, yOff); } } } -void ReturnDecorationPrompt(u8 taskId) +static void ReturnDecorationPrompt(u8 taskId) { DisplayYesNoMenuDefaultYes(); DoYesNoFuncWithChoice(taskId, &sReturnDecorationYesNoFunctions); } -void PutAwayDecoration(u8 taskId) +static void PutAwayDecoration(u8 taskId) { FadeScreen(FADE_TO_BLACK, 0); - gTasks[taskId].data[2] = 0; - gTasks[taskId].func = sub_81298EC; + gTasks[taskId].tState = 0; + gTasks[taskId].func = Task_PutAwayDecoration; } -void StopPuttingAwayDecorationsPrompt(u8 taskId) +static void StopPuttingAwayDecorationsPrompt(u8 taskId) { DisplayYesNoMenuDefaultYes(); DoYesNoFuncWithChoice(taskId, &sStopPuttingAwayDecorationsYesNoFunctions); } -void StopPuttingAwayDecorations(u8 taskId) +static void StopPuttingAwayDecorations(u8 taskId) { ClearDialogWindowAndFrame(0, 0); - sub_812A22C(taskId); + StopPuttingAwayDecorations_(taskId); } -void sub_812A22C(u8 taskId) +static void StopPuttingAwayDecorations_(u8 taskId) { FadeScreen(FADE_TO_BLACK, 0); - gTasks[taskId].data[2] = 0; - gTasks[taskId].func = sub_812A25C; + gTasks[taskId].tState = 0; + gTasks[taskId].func = Task_StopPuttingAwayDecorations; } -void sub_812A25C(u8 taskId) +static void Task_StopPuttingAwayDecorations(u8 taskId) { - switch (gTasks[taskId].data[2]) + switch (gTasks[taskId].tState) { case 0: if (!gPaletteFade.active) { - sub_8127B04(taskId); - gTasks[taskId].data[2] = 1; + WarpToInitialPosition(taskId); + gTasks[taskId].tState = 1; } break; case 1: - sub_812A3C8(); - gFieldCallback = sub_812A334; + FreePlayerSpritePalette(); + gFieldCallback = FieldCB_StopPuttingAwayDecorations; SetMainCallback2(CB2_ReturnToField); DestroyTask(taskId); break; } } -void sub_812A2C4(u8 taskId) +static void Task_ReinitializeDecorationMenuHandler(u8 taskId) { s16 *data = gTasks[taskId].data; - switch (data[2]) + switch (tState) { case 0: HideSecretBaseDecorationSprites(); - data[2]++; + tState++; break; case 1: ScriptContext1_SetupScript(SecretBase_EventScript_InitDecorations); - data[2]++; + tState++; break; case 2: ScriptContext2_Enable(); - data[2]++; + tState++; break; case 3: if (IsWeatherNotFadingIn() == TRUE) @@ -2621,18 +2655,18 @@ void sub_812A2C4(u8 taskId) } } -void sub_812A334(void) +static void FieldCB_StopPuttingAwayDecorations(void) { u8 taskId; FadeInFromBlack(); DrawDialogueFrame(0, 1); InitDecorationActionsWindow(); - taskId = CreateTask(sub_812A2C4, 8); - gTasks[taskId].data[2] = 0; + taskId = CreateTask(Task_ReinitializeDecorationMenuHandler, 8); + gTasks[taskId].tState = 0; } -void sub_812A36C(struct Sprite *sprite) +static void InitializeCameraSprite1(struct Sprite *sprite) { sprite->data[0]++; sprite->data[0] &= 0x1F; @@ -2642,20 +2676,20 @@ void sub_812A36C(struct Sprite *sprite) sprite->invisible = FALSE; } -void sub_812A39C(void) +static void LoadPlayerSpritePalette(void) { if (gSaveBlock2Ptr->playerGender == MALE) - LoadSpritePalette(&gUnknown_085A73D8); + LoadSpritePalette(&sSpritePal_PuttingAwayCursorBrendan); else - LoadSpritePalette(&gUnknown_085A73E0); + LoadSpritePalette(&sSpritePal_PuttingAwayCursorMay); } -void sub_812A3C8(void) +static void FreePlayerSpritePalette(void) { FreeSpritePaletteByTag(PLACE_DECORATION_PLAYER_TAG); } -void sub_812A3D4(u8 taskId) +static void DecorationItemsMenuAction_AttemptToss(u8 taskId) { if (IsSelectedDecorInThePC() == TRUE) { @@ -2666,23 +2700,22 @@ void sub_812A3D4(u8 taskId) else { StringExpandPlaceholders(gStringVar4, gText_CantThrowAwayInUse); - DisplayItemMessageOnField(taskId, gStringVar4, sub_8127A5C); + DisplayItemMessageOnField(taskId, gStringVar4, ReturnToDecorationItemsAfterInvalidSelection); } } -void TossDecorationPrompt(u8 taskId) +static void TossDecorationPrompt(u8 taskId) { DisplayYesNoMenuDefaultYes(); DoYesNoFuncWithChoice(taskId, &sTossDecorationYesNoFunctions); } -void TossDecoration(u8 taskId) +static void TossDecoration(u8 taskId) { gCurDecorationItems[gCurDecorationIndex] = DECOR_NONE; sNumOwnedDecorationsInCurCategory = GetNumOwnedDecorationsInCategory(sCurDecorationCategory); CondenseDecorationsInCategory(sCurDecorationCategory); IdentifyOwnedDecorationsCurrentlyInUseInternal(taskId); StringExpandPlaceholders(gStringVar4, gText_DecorationThrownAway); - DisplayItemMessageOnField(taskId, gStringVar4, sub_8127A5C); + DisplayItemMessageOnField(taskId, gStringVar4, ReturnToDecorationItemsAfterInvalidSelection); } - diff --git a/src/decoration_inventory.c b/src/decoration_inventory.c index 80646c69c..af1071b1b 100644 --- a/src/decoration_inventory.c +++ b/src/decoration_inventory.c @@ -1,71 +1,51 @@ - -// Includes #include "global.h" #include "constants/decorations.h" #include "decoration.h" #include "decoration_inventory.h" -// Static type declarations - -// Static RAM declarations - -EWRAM_DATA struct DecorationInventory gDecorationInventories[8] = {}; - -// Static ROM declarations - -// .rodata - -// .text +EWRAM_DATA struct DecorationInventory gDecorationInventories[DECORCAT_COUNT] = {}; #define SET_DECOR_INV(i, ptr) {\ gDecorationInventories[i].items = ptr;\ - gDecorationInventories[i].size = sizeof(ptr);\ + gDecorationInventories[i].size = ARRAY_COUNT(ptr);\ } void SetDecorationInventoriesPointers(void) { - SET_DECOR_INV(0, gSaveBlock1Ptr->decorDesk); - SET_DECOR_INV(1, gSaveBlock1Ptr->decorChair); - SET_DECOR_INV(2, gSaveBlock1Ptr->decorPlant); - SET_DECOR_INV(3, gSaveBlock1Ptr->decorOrnament); - SET_DECOR_INV(4, gSaveBlock1Ptr->decorMat); - SET_DECOR_INV(5, gSaveBlock1Ptr->decorPoster); - SET_DECOR_INV(6, gSaveBlock1Ptr->decorDoll); - SET_DECOR_INV(7, gSaveBlock1Ptr->decorCushion); + SET_DECOR_INV(DECORCAT_DESK, gSaveBlock1Ptr->decorationDesks); + SET_DECOR_INV(DECORCAT_CHAIR, gSaveBlock1Ptr->decorationChairs); + SET_DECOR_INV(DECORCAT_PLANT, gSaveBlock1Ptr->decorationPlants); + SET_DECOR_INV(DECORCAT_ORNAMENT, gSaveBlock1Ptr->decorationOrnaments); + SET_DECOR_INV(DECORCAT_MAT, gSaveBlock1Ptr->decorationMats); + SET_DECOR_INV(DECORCAT_POSTER, gSaveBlock1Ptr->decorationPosters); + SET_DECOR_INV(DECORCAT_DOLL, gSaveBlock1Ptr->decorationDolls); + SET_DECOR_INV(DECORCAT_CUSHION, gSaveBlock1Ptr->decorationCushions); InitDecorationContextItems(); } -static void ClearDecorationInventory(u8 idx) +static void ClearDecorationInventory(u8 category) { u8 i; - - for (i = 0; i < gDecorationInventories[idx].size; i ++) - { - gDecorationInventories[idx].items[i] = DECOR_NONE; - } + for (i = 0; i < gDecorationInventories[category].size; i ++) + gDecorationInventories[category].items[i] = DECOR_NONE; } void ClearDecorationInventories(void) { - u8 idx; - - for (idx = 0; idx < 8; idx ++) - { - ClearDecorationInventory(idx); - } + u8 category; + for (category = 0; category < 8; category++) + ClearDecorationInventory(category); } -s8 GetFirstEmptyDecorSlot(u8 idx) +s8 GetFirstEmptyDecorSlot(u8 category) { s8 i; - - for (i = 0; i < (s8)gDecorationInventories[idx].size; i ++) + for (i = 0; i < (s8)gDecorationInventories[category].size; i++) { - if (gDecorationInventories[idx].items[i] == DECOR_NONE) - { + if (gDecorationInventories[category].items[i] == DECOR_NONE) return i; - } } + return -1; } @@ -78,10 +58,9 @@ bool8 CheckHasDecoration(u8 decor) for (i = 0; i < gDecorationInventories[category].size; i ++) { if (gDecorationInventories[category].items[i] == decor) - { return TRUE; - } } + return FALSE; } @@ -91,15 +70,11 @@ bool8 DecorationAdd(u8 decor) s8 idx; if (decor == DECOR_NONE) - { return FALSE; - } category = gDecorations[decor].category; idx = GetFirstEmptyDecorSlot(category); if (idx == -1) - { return FALSE; - } gDecorationInventories[category].items[idx] = decor; return TRUE; } @@ -107,13 +82,9 @@ bool8 DecorationAdd(u8 decor) bool8 DecorationCheckSpace(u8 decor) { if (decor == DECOR_NONE) - { return FALSE; - } if (GetFirstEmptyDecorSlot(gDecorations[decor].category) == -1) - { return FALSE; - } return TRUE; } @@ -124,9 +95,8 @@ s8 DecorationRemove(u8 decor) i = 0; if (decor == DECOR_NONE) - { return 0; - } + for (i = 0; i < gDecorationInventories[gDecorations[decor].category].size; i ++) { category = gDecorations[decor].category; @@ -137,6 +107,7 @@ s8 DecorationRemove(u8 decor) return 1; } } + return 0; } @@ -160,19 +131,18 @@ void CondenseDecorationsInCategory(u8 category) } } -u8 GetNumOwnedDecorationsInCategory(u8 idx) +u8 GetNumOwnedDecorationsInCategory(u8 category) { u8 i; u8 ct; ct = 0; - for (i = 0; i < gDecorationInventories[idx].size; i ++) + for (i = 0; i < gDecorationInventories[category].size; i++) { - if (gDecorationInventories[idx].items[i] != DECOR_NONE) - { - ct ++; - } + if (gDecorationInventories[category].items[i] != DECOR_NONE) + ct++; } + return ct; } diff --git a/src/digit_obj_util.c b/src/digit_obj_util.c new file mode 100644 index 000000000..fe5d49e69 --- /dev/null +++ b/src/digit_obj_util.c @@ -0,0 +1,450 @@ +#include "global.h" +#include "digit_obj_util.h" +#include "malloc.h" +#include "decompress.h" +#include "main.h" +#include "battle_main.h" + +struct DigitPrinter +{ + bool8 isActive; + u8 firstOamId; + u8 strConvMode; + u8 oamCount; + u8 palTagIndex; + u8 size; + u8 shape; + u8 priority; + u8 xDelta; + u8 tilesPerImage; + u16 tileStart; + s16 x; + s16 y; + u16 tileTag; + u16 palTag; + u32 pow10; + s32 lastPrinted; +}; + +struct DigitPrinterAlloc +{ + u32 count; + struct DigitPrinter *array; +}; + +// this file's functions +static u8 GetFirstOamId(u8 oamCount);; +static void CopyWorkToOam(struct DigitPrinter *objWork); +static void DrawNumObjsLeadingZeros(struct DigitPrinter *objWork, s32 num, bool32 sign); +static void DrawNumObjsMinusInFront(struct DigitPrinter *objWork, s32 num, bool32 sign); +static void DrawNumObjsMinusInBack(struct DigitPrinter *objWork, s32 num, bool32 sign); +static bool32 SharesTileWithAnyActive(u32 id); +static bool32 SharesPalWithAnyActive(u32 id); + +// ewram +static EWRAM_DATA struct DigitPrinterAlloc *sOamWork = {0}; + +// const rom data +static const u8 sTilesPerImage[4][4] = +{ + [ST_OAM_SQUARE] = { + [ST_OAM_SIZE_0] = 0x01, // SPRITE_SIZE_8x8 + [ST_OAM_SIZE_1] = 0x04, // SPRITE_SIZE_16x16 + [ST_OAM_SIZE_2] = 0x10, // SPRITE_SIZE_32x32 + [ST_OAM_SIZE_3] = 0x40 // SPRITE_SIZE_64x64 + }, + [ST_OAM_H_RECTANGLE] = { + [ST_OAM_SIZE_0] = 0x02, // SPRITE_SIZE_16x8 + [ST_OAM_SIZE_1] = 0x04, // SPRITE_SIZE_32x8 + [ST_OAM_SIZE_2] = 0x08, // SPRITE_SIZE_32x16 + [ST_OAM_SIZE_3] = 0x20 // SPRITE_SIZE_64x32 + }, + [ST_OAM_V_RECTANGLE] = { + [ST_OAM_SIZE_0] = 0x02, // SPRITE_SIZE_8x16 + [ST_OAM_SIZE_1] = 0x04, // SPRITE_SIZE_8x32 + [ST_OAM_SIZE_2] = 0x08, // SPRITE_SIZE_16x32 + [ST_OAM_SIZE_3] = 0x20 // SPRITE_SIZE_32x64 + } +}; + +// code +bool32 DigitObjUtil_Init(u32 count) +{ + u32 i; + + if (sOamWork != NULL) + DigitObjUtil_Free(); + + sOamWork = Alloc(sizeof(*sOamWork)); + if (sOamWork == NULL) + return FALSE; + + sOamWork->array = Alloc(sizeof(struct DigitPrinter) * count); + if (sOamWork->array == NULL) + { + Free(sOamWork); + return FALSE; + } + + sOamWork->count = count; + for (i = 0; i < count; i++) + { + sOamWork->array[i].isActive = FALSE; + sOamWork->array[i].firstOamId = 0xFF; + } + + return TRUE; +} + +void DigitObjUtil_Free(void) +{ + if (sOamWork != NULL) + { + if (sOamWork->array != NULL) + { + u32 i; + + for (i = 0; i < sOamWork->count; i++) + DigitObjUtil_DeletePrinter(i); + + Free(sOamWork->array); + } + + FREE_AND_SET_NULL(sOamWork); + } +} + +bool32 DigitObjUtil_CreatePrinter(u32 id, s32 num, const struct DigitObjUtilTemplate *template) +{ + u32 i; + + if (sOamWork == NULL) + return FALSE; + if (sOamWork->array[id].isActive) + return FALSE; + + sOamWork->array[id].firstOamId = GetFirstOamId(template->oamCount); + if (sOamWork->array[id].firstOamId == 0xFF) + return FALSE; + + sOamWork->array[id].tileStart = GetSpriteTileStartByTag(template->spriteSheet->tag); + if (sOamWork->array[id].tileStart == 0xFFFF) + { + if (template->spriteSheet->size != 0) + { + sOamWork->array[id].tileStart = LoadSpriteSheet(template->spriteSheet); + } + else + { + struct CompressedSpriteSheet compSpriteSheet; + + compSpriteSheet = *(struct CompressedSpriteSheet*)(template->spriteSheet); + compSpriteSheet.size = GetDecompressedDataSize(template->spriteSheet->data); + sOamWork->array[id].tileStart = LoadCompressedSpriteSheet(&compSpriteSheet); + } + + if (sOamWork->array[id].tileStart == 0xFFFF) + return FALSE; + } + + sOamWork->array[id].palTagIndex = IndexOfSpritePaletteTag(template->spritePal->tag); + if (sOamWork->array[id].palTagIndex == 0xFF) + sOamWork->array[id].palTagIndex = LoadSpritePalette(template->spritePal); + + sOamWork->array[id].strConvMode = template->strConvMode; + sOamWork->array[id].oamCount = template->oamCount; + sOamWork->array[id].x = template->x; + sOamWork->array[id].y = template->y; + sOamWork->array[id].shape = template->shape; + sOamWork->array[id].size = template->size; + sOamWork->array[id].priority = template->priority; + sOamWork->array[id].xDelta = template->xDelta; + sOamWork->array[id].tilesPerImage = GetTilesPerImage(template->shape, template->size); + sOamWork->array[id].tileTag = template->spriteSheet->tag; + sOamWork->array[id].palTag = template->spritePal->tag; + sOamWork->array[id].isActive = TRUE; + + // Decimal left shift + sOamWork->array[id].pow10 = 1; + for (i = 1; i < template->oamCount; i++) + sOamWork->array[id].pow10 *= 10; + + CopyWorkToOam(&sOamWork->array[id]); + DigitObjUtil_PrintNumOn(id, num); + + return TRUE; +} + +static void CopyWorkToOam(struct DigitPrinter *objWork) +{ + u32 i; + u32 oamId = objWork->firstOamId; + u32 x = objWork->x; + u32 oamCount = objWork->oamCount + 1; + + CpuFill16(0, &gMain.oamBuffer[oamId], sizeof(struct OamData) * oamCount); + for (i = 0, oamId = objWork->firstOamId; i < oamCount; i++, oamId++) + { + gMain.oamBuffer[oamId].y = objWork->y; + gMain.oamBuffer[oamId].x = x; + gMain.oamBuffer[oamId].shape = objWork->shape; + gMain.oamBuffer[oamId].size = objWork->size; + gMain.oamBuffer[oamId].tileNum = objWork->tileStart; + gMain.oamBuffer[oamId].priority = objWork->priority; + gMain.oamBuffer[oamId].paletteNum = objWork->palTagIndex; + + x += objWork->xDelta; + } + + oamId--; + gMain.oamBuffer[oamId].x = objWork->x - objWork->xDelta; + gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_ERASE; + gMain.oamBuffer[oamId].tileNum = objWork->tileStart + (objWork->tilesPerImage * 10); +} + +void DigitObjUtil_PrintNumOn(u32 id, s32 num) +{ + bool32 sign; + + if (sOamWork == NULL) + return; + if (!sOamWork->array[id].isActive) + return; + + sOamWork->array[id].lastPrinted = num; + if (num < 0) + { + sign = TRUE; + num *= -1; + } + else + { + sign = FALSE; + } + + switch (sOamWork->array[id].strConvMode) + { + case 0: + default: + DrawNumObjsLeadingZeros(&sOamWork->array[id], num, sign); + break; + case 1: + DrawNumObjsMinusInFront(&sOamWork->array[id], num, sign); + break; + case 2: + DrawNumObjsMinusInBack(&sOamWork->array[id], num, sign); + break; + } +} + +static void DrawNumObjsLeadingZeros(struct DigitPrinter *objWork, s32 num, bool32 sign) +{ + u32 pow10 = objWork->pow10; + u32 oamId = objWork->firstOamId; + + while (pow10 != 0) + { + u32 digit = num / pow10; + num -= (digit * pow10); + pow10 /= 10; + + gMain.oamBuffer[oamId].tileNum = (digit * objWork->tilesPerImage) + objWork->tileStart; + oamId++; + } + + if (sign) + gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_OFF; + else + gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_ERASE; +} + +static void DrawNumObjsMinusInFront(struct DigitPrinter *objWork, s32 num, bool32 sign) +{ + u32 pow10 = objWork->pow10; + static int oamId; + static int curDigit; + static int firstDigit; + + oamId = objWork->firstOamId; + curDigit = 0; + firstDigit = -1; + + while (pow10 != 0) + { + u32 digit = num / pow10; + num -= (digit * pow10); + pow10 /= 10; + + if (digit != 0 || firstDigit != -1 || pow10 == 0) + { + gMain.oamBuffer[oamId].tileNum = (digit * objWork->tilesPerImage) + objWork->tileStart; + gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_OFF; + + if (firstDigit == -1) + firstDigit = curDigit; + } + else + { + gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_ERASE; + } + + oamId++; + curDigit++; + } + + if (sign) + { + gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_OFF; + gMain.oamBuffer[oamId].x = objWork->x + ((firstDigit - 1) * objWork->xDelta); + } + else + { + gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_ERASE; + } +} + +static void DrawNumObjsMinusInBack(struct DigitPrinter *objWork, s32 num, bool32 sign) +{ + u32 pow10 = objWork->pow10; + u32 oamId = objWork->firstOamId; + bool32 printingDigits = FALSE; + s32 nsprites = 0; + + while (pow10 != 0) + { + u32 digit = num / pow10; + num -= (digit * pow10); + pow10 /= 10; + + if (digit != 0 || printingDigits || pow10 == 0) + { + printingDigits = TRUE; + gMain.oamBuffer[oamId].tileNum = (digit * objWork->tilesPerImage) + objWork->tileStart; + gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_OFF; + + oamId++; + nsprites++; + } + } + + while (nsprites < objWork->oamCount) + { + gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_ERASE; + oamId++; + nsprites++; + } + + if (sign) + gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_OFF; + else + gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_ERASE; +} + +void DigitObjUtil_DeletePrinter(u32 id) +{ + s32 oamId, oamCount, i; + + if (sOamWork == NULL) + return; + if (!sOamWork->array[id].isActive) + return; + + oamCount = sOamWork->array[id].oamCount + 1; + oamId = sOamWork->array[id].firstOamId; + + for (i = 0; i < oamCount; i++, oamId++) + gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_ERASE; + + if (!SharesTileWithAnyActive(id)) + FreeSpriteTilesByTag(sOamWork->array[id].tileTag); + if (!SharesPalWithAnyActive(id)) + FreeSpritePaletteByTag(sOamWork->array[id].palTag); + + sOamWork->array[id].isActive = FALSE; +} + +void DigitObjUtil_HideOrShow(u32 id, bool32 hide) +{ + s32 oamId, oamCount, i; + + if (sOamWork == NULL) + return; + if (!sOamWork->array[id].isActive) + return; + + oamCount = sOamWork->array[id].oamCount + 1; + oamId = sOamWork->array[id].firstOamId; + if (hide) + { + for (i = 0; i < oamCount; i++, oamId++) + gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_ERASE; + } + else + { + for (i = 0; i < oamCount; i++, oamId++) + gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_OFF; + + DigitObjUtil_PrintNumOn(id, sOamWork->array[id].lastPrinted); + } +} + +static u8 GetFirstOamId(u8 oamCount) +{ + u32 i; + u16 firstOamId = 64; + + for (i = 0; i < sOamWork->count; i++) + { + if (!sOamWork->array[i].isActive) + { + if (sOamWork->array[i].firstOamId != 0xFF && sOamWork->array[i].oamCount <= oamCount) + return sOamWork->array[i].firstOamId; + } + else + { + firstOamId += 1 + sOamWork->array[i].oamCount; + } + } + + if (firstOamId + oamCount + 1 > 128) + return 0xFF; + else + return firstOamId; +} + +static bool32 SharesTileWithAnyActive(u32 id) +{ + u32 i; + + for (i = 0; i < sOamWork->count; i++) + { + if (sOamWork->array[i].isActive && i != id + && sOamWork->array[i].tileTag == sOamWork->array[id].tileTag) + { + return TRUE; + } + } + + return FALSE; +} + +static bool32 SharesPalWithAnyActive(u32 id) +{ + u32 i; + + for (i = 0; i < sOamWork->count; i++) + { + if (sOamWork->array[i].isActive && i != id + && sOamWork->array[i].palTag == sOamWork->array[id].palTag) + { + return TRUE; + } + } + + return FALSE; +} + +u8 GetTilesPerImage(u32 shape, u32 size) +{ + return sTilesPerImage[shape][size]; +} diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index 40074e0af..936c1828f 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -12,7 +12,7 @@ #include "m4a.h" #include "main.h" #include "palette.h" -#include "pokemon_jump.h" +#include "minigame_countdown.h" #include "random.h" #include "save.h" #include "script.h" @@ -667,7 +667,7 @@ static void sub_8024E38(void) switch (gUnknown_02022C98->unk10) { case 0: - sub_802EB24(7, 8, 120, 80, 0); + StartMinigameCountdown(7, 8, 120, 80, 0); gUnknown_02022C98->unk10++; break; case 1: @@ -682,7 +682,7 @@ static void sub_8024E38(void) } break; case 3: - if (!sub_802EB84()) + if (!IsMinigameCountdownRunning()) { gUnknown_02022C98->unk10++; } diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 464e6acec..09cdd94cd 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -1754,7 +1754,7 @@ static void SetPlayerAvatarObjectEventIdAndObjectId(u8 objectEventId, u8 spriteI gPlayerAvatar.objectEventId = objectEventId; gPlayerAvatar.spriteId = spriteId; gPlayerAvatar.gender = GetPlayerAvatarGenderByGraphicsId(gObjectEvents[objectEventId].graphicsId); - SetPlayerAvatarExtraStateTransition(gObjectEvents[objectEventId].graphicsId, 0x20); + SetPlayerAvatarExtraStateTransition(gObjectEvents[objectEventId].graphicsId, PLAYER_AVATAR_FLAG_5); } void ObjectEventSetGraphicsId(struct ObjectEvent *objectEvent, u8 graphicsId) diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index ebab51ed8..35bbb1e03 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -59,8 +59,8 @@ static bool8 ForcedMovement_SlideSouth(void); static bool8 ForcedMovement_SlideNorth(void); static bool8 ForcedMovement_SlideWest(void); static bool8 ForcedMovement_SlideEast(void); -static bool8 ForcedMovement_0xBB(void); -static bool8 ForcedMovement_0xBC(void); +static bool8 ForcedMovement_MatJump(void); +static bool8 ForcedMovement_MatSpin(void); static bool8 ForcedMovement_MuddySlope(void); static void MovePlayerNotOnBike(u8, u16); @@ -99,10 +99,10 @@ static void PlayCollisionSoundIfNotFacingWarp(u8 a); static void sub_808C280(struct ObjectEvent *); static void StartStrengthAnim(u8, u8); -static void Task_BumpBoulder(u8 taskId); -static u8 sub_808C3A4(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject); -static u8 do_boulder_dust(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject); -static u8 sub_808C484(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject); +static void Task_PushBoulder(u8 taskId); +static u8 PushBoulder_Start(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject); +static u8 PushBoulder_Move(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject); +static u8 PushBoulder_End(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject); static void DoPlayerMatJump(void); static void DoPlayerAvatarSecretBaseMatJump(u8 taskId); @@ -182,8 +182,8 @@ static bool8 (*const sForcedMovementFuncs[])(void) = ForcedMovement_SlideWest, ForcedMovement_SlideEast, ForcedMovement_PushedSouthByCurrent, - ForcedMovement_0xBB, - ForcedMovement_0xBC, + ForcedMovement_MatJump, + ForcedMovement_MatSpin, ForcedMovement_MuddySlope, }; @@ -211,16 +211,16 @@ static const u8 sAcroBikeTrickCollisionTypes[] = { COLLISION_HORIZONTAL_RAIL, }; -static void (*const gUnknown_084974B8[])(struct ObjectEvent *) = +static void (*const sPlayerAvatarTransitionFuncs[])(struct ObjectEvent *) = { - PlayerAvatarTransition_Normal, - PlayerAvatarTransition_MachBike, - PlayerAvatarTransition_AcroBike, - PlayerAvatarTransition_Surfing, - PlayerAvatarTransition_Underwater, - PlayerAvatarTransition_ReturnToField, - PlayerAvatarTransition_Dummy, - PlayerAvatarTransition_Dummy, + [PLAYER_AVATAR_STATE_NORMAL] = PlayerAvatarTransition_Normal, + [PLAYER_AVATAR_STATE_MACH_BIKE] = PlayerAvatarTransition_MachBike, + [PLAYER_AVATAR_STATE_ACRO_BIKE] = PlayerAvatarTransition_AcroBike, + [PLAYER_AVATAR_STATE_SURFING] = PlayerAvatarTransition_Surfing, + [PLAYER_AVATAR_STATE_UNDERWATER] = PlayerAvatarTransition_Underwater, + [PLAYER_AVATAR_STATE_FIELD_MOVE] = PlayerAvatarTransition_ReturnToField, + [PLAYER_AVATAR_STATE_FISHING] = PlayerAvatarTransition_Dummy, + [PLAYER_AVATAR_STATE_WATERING] = PlayerAvatarTransition_Dummy, }; static bool8 (*const sArrowWarpMetatileBehaviorChecks[])(u8) = @@ -259,23 +259,23 @@ static const u8 sFRLGAvatarGfxIds[] = {OBJ_EVENT_GFX_RED, OBJ_EVENT_GFX_LEAF}; static const u8 sRSAvatarGfxIds[] = {OBJ_EVENT_GFX_LINK_RS_BRENDAN, OBJ_EVENT_GFX_LINK_RS_MAY}; -static const u8 gUnknown_0849750C[2][5][2] = +static const u8 sPlayerAvatarGfxToStateFlag[2][5][2] = { - //male + [MALE] = { - {OBJ_EVENT_GFX_BRENDAN_NORMAL, 1}, - {OBJ_EVENT_GFX_BRENDAN_MACH_BIKE, 2}, - {OBJ_EVENT_GFX_BRENDAN_ACRO_BIKE, 4}, - {OBJ_EVENT_GFX_BRENDAN_SURFING, 8}, - {OBJ_EVENT_GFX_BRENDAN_UNDERWATER, 16}, + {OBJ_EVENT_GFX_BRENDAN_NORMAL, PLAYER_AVATAR_FLAG_ON_FOOT}, + {OBJ_EVENT_GFX_BRENDAN_MACH_BIKE, PLAYER_AVATAR_FLAG_MACH_BIKE}, + {OBJ_EVENT_GFX_BRENDAN_ACRO_BIKE, PLAYER_AVATAR_FLAG_ACRO_BIKE}, + {OBJ_EVENT_GFX_BRENDAN_SURFING, PLAYER_AVATAR_FLAG_SURFING}, + {OBJ_EVENT_GFX_BRENDAN_UNDERWATER, PLAYER_AVATAR_FLAG_UNDERWATER}, }, - //female + [FEMALE] = { - {OBJ_EVENT_GFX_MAY_NORMAL, 1}, - {OBJ_EVENT_GFX_MAY_MACH_BIKE, 2}, - {OBJ_EVENT_GFX_MAY_ACRO_BIKE, 4}, - {OBJ_EVENT_GFX_MAY_SURFING, 8}, - {OBJ_EVENT_GFX_MAY_UNDERWATER, 16}, + {OBJ_EVENT_GFX_MAY_NORMAL, PLAYER_AVATAR_FLAG_ON_FOOT}, + {OBJ_EVENT_GFX_MAY_MACH_BIKE, PLAYER_AVATAR_FLAG_MACH_BIKE}, + {OBJ_EVENT_GFX_MAY_ACRO_BIKE, PLAYER_AVATAR_FLAG_ACRO_BIKE}, + {OBJ_EVENT_GFX_MAY_SURFING, PLAYER_AVATAR_FLAG_SURFING}, + {OBJ_EVENT_GFX_MAY_UNDERWATER, PLAYER_AVATAR_FLAG_UNDERWATER}, } }; @@ -287,11 +287,11 @@ static bool8 (*const sArrowWarpMetatileBehaviorChecks2[])(u8) = //Duplicate of MetatileBehavior_IsEastArrowWarp, }; -static bool8 (*const gUnknown_08497530[])(struct Task *, struct ObjectEvent *, struct ObjectEvent *) = +static bool8 (*const sPushBoulderFuncs[])(struct Task *, struct ObjectEvent *, struct ObjectEvent *) = { - sub_808C3A4, - do_boulder_dust, - sub_808C484, + PushBoulder_Start, + PushBoulder_Move, + PushBoulder_End, }; static bool8 (*const sPlayerAvatarSecretBaseMatJump[])(struct Task *, struct ObjectEvent *) = @@ -547,13 +547,13 @@ static bool8 ForcedMovement_SlideEast(void) return ForcedMovement_Slide(DIR_EAST, PlayerGoSpeed2); } -static bool8 ForcedMovement_0xBB(void) +static bool8 ForcedMovement_MatJump(void) { DoPlayerMatJump(); return TRUE; } -static bool8 ForcedMovement_0xBC(void) +static bool8 ForcedMovement_MatSpin(void) { DoPlayerMatSpin(); return TRUE; @@ -807,23 +807,23 @@ bool8 IsPlayerCollidingWithFarawayIslandMew(u8 direction) void SetPlayerAvatarTransitionFlags(u16 transitionFlags) { - gPlayerAvatar.unk1 |= transitionFlags; + gPlayerAvatar.transitionFlags |= transitionFlags; DoPlayerAvatarTransition(); } static void DoPlayerAvatarTransition(void) { u8 i; - u8 flags = gPlayerAvatar.unk1; + u8 flags = gPlayerAvatar.transitionFlags; if (flags != 0) { - for (i = 0; i < 8; i++, flags >>= 1) + for (i = 0; i < ARRAY_COUNT(sPlayerAvatarTransitionFuncs); i++, flags >>= 1) { if (flags & 1) - gUnknown_084974B8[i](&gObjectEvents[gPlayerAvatar.objectEventId]); + sPlayerAvatarTransitionFuncs[i](&gObjectEvents[gPlayerAvatar.objectEventId]); } - gPlayerAvatar.unk1 = 0; + gPlayerAvatar.transitionFlags = 0; } } @@ -1186,12 +1186,12 @@ void sub_808BC90(s16 x, s16 y) MoveObjectEventToMapCoords(&gObjectEvents[gPlayerAvatar.objectEventId], x, y); } -u8 TestPlayerAvatarFlags(u8 a) +u8 TestPlayerAvatarFlags(u8 flag) { - return gPlayerAvatar.flags & a; + return gPlayerAvatar.flags & flag; } -u8 sub_808BCD0(void) +u8 GetPlayerAvatarFlags(void) { return gPlayerAvatar.flags; } @@ -1335,32 +1335,32 @@ static u8 GetPlayerAvatarStateTransitionByGraphicsId(u8 graphicsId, u8 gender) { u8 i; - for (i = 0; i < 5; i++) + for (i = 0; i < ARRAY_COUNT(sPlayerAvatarGfxToStateFlag[0]); i++) { - if (gUnknown_0849750C[gender][i][0] == graphicsId) - return gUnknown_0849750C[gender][i][1]; + if (sPlayerAvatarGfxToStateFlag[gender][i][0] == graphicsId) + return sPlayerAvatarGfxToStateFlag[gender][i][1]; } - return 1; + return PLAYER_AVATAR_FLAG_ON_FOOT; } u8 GetPlayerAvatarGraphicsIdByCurrentState(void) { u8 i; - u8 r5 = gPlayerAvatar.flags; + u8 flags = gPlayerAvatar.flags; - for (i = 0; i < 5; i++) + for (i = 0; i < ARRAY_COUNT(sPlayerAvatarGfxToStateFlag[0]); i++) { - if (gUnknown_0849750C[gPlayerAvatar.gender][i][1] & r5) - return gUnknown_0849750C[gPlayerAvatar.gender][i][0]; + if (sPlayerAvatarGfxToStateFlag[gPlayerAvatar.gender][i][1] & flags) + return sPlayerAvatarGfxToStateFlag[gPlayerAvatar.gender][i][0]; } return 0; } -void SetPlayerAvatarExtraStateTransition(u8 graphicsId, u8 b) +void SetPlayerAvatarExtraStateTransition(u8 graphicsId, u8 transitionFlag) { - u8 unk = GetPlayerAvatarStateTransitionByGraphicsId(graphicsId, gPlayerAvatar.gender); + u8 stateFlag = GetPlayerAvatarStateTransitionByGraphicsId(graphicsId, gPlayerAvatar.gender); - gPlayerAvatar.unk1 |= unk | b; + gPlayerAvatar.transitionFlags |= stateFlag | transitionFlag; DoPlayerAvatarTransition(); } @@ -1384,7 +1384,7 @@ void InitPlayerAvatar(s16 x, s16 y, u8 direction, u8 gender) playerObjEventTemplate.flagId = 0; objectEventId = SpawnSpecialObjectEvent(&playerObjEventTemplate); objectEvent = &gObjectEvents[objectEventId]; - objectEvent->isPlayer = 1; + objectEvent->isPlayer = TRUE; objectEvent->warpArrowSpriteId = CreateWarpArrowSprite(); ObjectEventTurn(objectEvent, direction); ClearPlayerAvatarInfo(); @@ -1453,22 +1453,22 @@ static void sub_808C280(struct ObjectEvent *objectEvent) static void StartStrengthAnim(u8 a, u8 b) { - u8 taskId = CreateTask(Task_BumpBoulder, 0xFF); + u8 taskId = CreateTask(Task_PushBoulder, 0xFF); gTasks[taskId].data[1] = a; gTasks[taskId].data[2] = b; - Task_BumpBoulder(taskId); + Task_PushBoulder(taskId); } -static void Task_BumpBoulder(u8 taskId) +static void Task_PushBoulder(u8 taskId) { - while (gUnknown_08497530[gTasks[taskId].data[0]](&gTasks[taskId], + while (sPushBoulderFuncs[gTasks[taskId].data[0]](&gTasks[taskId], &gObjectEvents[gPlayerAvatar.objectEventId], &gObjectEvents[gTasks[taskId].data[1]])) ; } -static bool8 sub_808C3A4(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject) +static bool8 PushBoulder_Start(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject) { ScriptContext2_Enable(); gPlayerAvatar.preventStep = TRUE; @@ -1476,7 +1476,7 @@ static bool8 sub_808C3A4(struct Task *task, struct ObjectEvent *playerObject, st return FALSE; } -static bool8 do_boulder_dust(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject) +static bool8 PushBoulder_Move(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject) { if (ObjectEventIsHeldMovementActive(playerObject)) { @@ -1506,7 +1506,7 @@ static bool8 do_boulder_dust(struct Task *task, struct ObjectEvent *playerObject return FALSE; } -static bool8 sub_808C484(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject) +static bool8 PushBoulder_End(struct Task *task, struct ObjectEvent *playerObject, struct ObjectEvent *strengthObject) { if (ObjectEventCheckHeldMovementStatus(playerObject) && ObjectEventCheckHeldMovementStatus(strengthObject)) @@ -1515,7 +1515,7 @@ static bool8 sub_808C484(struct Task *task, struct ObjectEvent *playerObject, st ObjectEventClearHeldMovementIfFinished(strengthObject); gPlayerAvatar.preventStep = FALSE; ScriptContext2_Disable(); - DestroyTask(FindTaskIdByFunc(Task_BumpBoulder)); + DestroyTask(FindTaskIdByFunc(Task_PushBoulder)); } return FALSE; } @@ -1545,7 +1545,7 @@ static u8 PlayerAvatar_DoSecretBaseMatJump(struct Task *task, struct ObjectEvent if (task->data[1] > 1) { gPlayerAvatar.preventStep = FALSE; - gPlayerAvatar.unk1 |= 0x20; + gPlayerAvatar.transitionFlags |= PLAYER_AVATAR_FLAG_5; DestroyTask(FindTaskIdByFunc(DoPlayerAvatarSecretBaseMatJump)); } } diff --git a/src/field_region_map.c b/src/field_region_map.c index 184c49b40..57f95f93e 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, ARRAY_COUNT(sFieldRegionMapBgTemplates)); + 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 8699bce78..9f1f12a47 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/fldeff_misc.c b/src/fldeff_misc.c index 60d1ea072..def86ab1b 100644 --- a/src/fldeff_misc.c +++ b/src/fldeff_misc.c @@ -1260,7 +1260,7 @@ static void Task_WateringBerryTreeAnim_2(u8 taskId) static void Task_WateringBerryTreeAnim_3(u8 taskId) { - SetPlayerAvatarTransitionFlags(sub_808BCD0()); + SetPlayerAvatarTransitionFlags(GetPlayerAvatarFlags()); DestroyTask(taskId); EnableBothScriptContexts(); } diff --git a/src/frontier_util.c b/src/frontier_util.c index f46c60391..668771375 100644 --- a/src/frontier_util.c +++ b/src/frontier_util.c @@ -94,7 +94,7 @@ static const u8 sFrontierBrainStreakAppearances[NUM_FRONTIER_FACILITIES][4] = [FRONTIER_FACILITY_PYRAMID] = {21, 70, 35, 0}, }; -static const struct FrontierBrainMon sFrontierBrainsMons[][2][3] = +static const struct FrontierBrainMon sFrontierBrainsMons[][2][FRONTIER_PARTY_SIZE] = { [FRONTIER_FACILITY_TOWER] = { @@ -1778,9 +1778,9 @@ void ResetWinStreaks(void) s32 battleMode, lvlMode; gSaveBlock2Ptr->frontier.winStreakActiveFlags = 0; - for (battleMode = 0; battleMode < 4; battleMode++) + for (battleMode = 0; battleMode < FRONTIER_MODE_COUNT; battleMode++) { - for (lvlMode = 0; lvlMode < 2; lvlMode++) + for (lvlMode = 0; lvlMode < FRONTIER_LVL_TENT; lvlMode++) { gSaveBlock2Ptr->frontier.towerWinStreaks[battleMode][lvlMode] = 0; if (battleMode < FRONTIER_MODE_MULTIS) diff --git a/src/graphics.c b/src/graphics.c index 8978680c7..5df0bd9b1 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1340,32 +1340,27 @@ const u16 gFrontierPassMapCursor_Pal[] = INCBIN_U16("graphics/frontier_pass/map_ const u16 gFrontierPassMedalsSilver_Pal[] = INCBIN_U16("graphics/frontier_pass/silver.gbapal"); const u16 gFrontierPassMedalsGold_Pal[] = INCBIN_U16("graphics/frontier_pass/gold.gbapal"); -const u16 gPokedexText_Pal[] = INCBIN_U16("graphics/pokedex/text.gbapal"); - -const u16 gPokedexCaughtScreenFade_Pal[] = INCBIN_U16("graphics/pokedex/fade.gbapal"); - -const u16 gPokedexHoennBg_Pal[] = INCBIN_U16("graphics/pokedex/hoenn_bg.gbapal"); -const u16 gPokedexNationalBg_Pal[] = INCBIN_U16("graphics/pokedex/national_bg.gbapal"); - +// Pokedex +const u16 gPokedexBgHoenn_Pal[] = INCBIN_U16("graphics/pokedex/bg_hoenn.gbapal"); +const u16 gPokedexCaughtScreen_Pal[] = INCBIN_U16("graphics/pokedex/caught_screen.gbapal"); +const u16 gPokedexSearchResults_Pal[] = INCBIN_U16("graphics/pokedex/search_results_bg.gbapal"); +const u16 gPokedexBgNational_Pal[] = INCBIN_U16("graphics/pokedex/bg_national.gbapal"); const u32 gPokedexMenu_Gfx[] = INCBIN_U32("graphics/pokedex/menu.4bpp.lz"); -const u32 gPokedexMenu2_Gfx[] = INCBIN_U32("graphics/pokedex/menu2.4bpp.lz"); - +const u32 gPokedexInterface_Gfx[] = INCBIN_U32("graphics/pokedex/interface.4bpp.lz"); const u32 gUnused_PokedexNoBall[] = INCBIN_U32("graphics/pokedex/noball_unused.4bpp.lz"); - -const u32 gPokedexTilemap_StartMenu1[] = INCBIN_U32("graphics/pokedex/tilemap1.bin.lz"); -const u32 gPokedexTilemap_StartMenu2[] = INCBIN_U32("graphics/pokedex/tilemap2.bin.lz"); -const u32 gPokedexTilemap_Main[] = INCBIN_U32("graphics/pokedex/tilemap3.bin.lz"); -const u32 gPokedexTilemap_MainUnderlay[] = INCBIN_U32("graphics/pokedex/tilemap4.bin.lz"); -const u32 gPokedexTilemap_SizeScreen[] = INCBIN_U32("graphics/pokedex/tilemap5.bin.lz"); -const u32 gPokedexTilemap_ScreenSelectBar1[] = INCBIN_U32("graphics/pokedex/tilemap6.bin.lz"); -const u32 gPokedexTilemap_ScreenSelectBar2[] = INCBIN_U32("graphics/pokedex/tilemap7.bin.lz"); -const u32 gPokedexTilemap_DescriptionScreen[] = INCBIN_U32("graphics/pokedex/tilemap8.bin.lz"); -const u32 gPokedexTilemap_CryScreen[] = INCBIN_U32("graphics/pokedex/tilemap9.bin.lz"); - +const u32 gPokedexStartMenuMain_Tilemap[] = INCBIN_U32("graphics/pokedex/start_menu_main.bin.lz"); +const u32 gPokedexStartMenuSearchResults_Tilemap[] = INCBIN_U32("graphics/pokedex/start_menu_search_results.bin.lz"); +const u32 gPokedexList_Tilemap[] = INCBIN_U32("graphics/pokedex/list.bin.lz"); +const u32 gPokedexListUnderlay_Tilemap[] = INCBIN_U32("graphics/pokedex/list_underlay.bin.lz"); +const u32 gPokedexSizeScreen_Tilemap[] = INCBIN_U32("graphics/pokedex/size_screen.bin.lz"); +const u32 gPokedexScreenSelectBarMain_Tilemap[] = INCBIN_U32("graphics/pokedex/screen_select_bar_main.bin.lz"); +const u32 gPokedexScreenSelectBarSubmenu_Tilemap[] = INCBIN_U32("graphics/pokedex/screen_select_bar_submenu.bin.lz"); +const u32 gPokedexInfoScreen_Tilemap[] = INCBIN_U32("graphics/pokedex/info_screen.bin.lz"); +const u32 gPokedexCryScreen_Tilemap[] = INCBIN_U32("graphics/pokedex/cry_screen.bin.lz"); const u16 gPokedexSearchMenu_Pal[] = INCBIN_U16("graphics/pokedex/search_menu.gbapal"); const u32 gPokedexSearchMenu_Gfx[] = INCBIN_U32("graphics/pokedex/search_menu.4bpp.lz"); -const u32 gPokedexSearch1_Tilemap[] = INCBIN_U32("graphics/pokedex/search1.bin.lz"); -const u32 gPokedexSearch2_Tilemap[] = INCBIN_U32("graphics/pokedex/search2.bin.lz"); +const u32 gPokedexSearchMenuNational_Tilemap[] = INCBIN_U32("graphics/pokedex/search_menu_national.bin.lz"); +const u32 gPokedexSearchMenuHoenn_Tilemap[] = INCBIN_U32("graphics/pokedex/search_menu_hoenn.bin.lz"); const u16 gSummaryScreenPowAcc_Tilemap[] = INCBIN_U16("graphics/interface/powacc_tilemap.bin"); @@ -1436,8 +1431,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/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/hall_of_fame.c b/src/hall_of_fame.c index 065d25582..05e4ed0aa 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -155,7 +155,7 @@ static const struct CompressedSpritePalette sHallOfFame_ConfettiSpritePalette[] {}, }; -static const s16 sHallOfFame_MonFullTeamPositions[6][4] = +static const s16 sHallOfFame_MonFullTeamPositions[PARTY_SIZE][4] = { {120, 210, 120, 40}, {326, 220, 56, 40}, @@ -165,7 +165,7 @@ static const s16 sHallOfFame_MonFullTeamPositions[6][4] = {310, -92, 40, 88} }; -static const s16 sHallOfFame_MonHalfTeamPositions[3][4] = +static const s16 sHallOfFame_MonHalfTeamPositions[PARTY_SIZE / 2][4] = { {120, 234, 120, 64}, {326, 244, 56, 64}, @@ -544,7 +544,7 @@ static void Task_Hof_DisplayMon(u8 taskId) u16 currMonId = gTasks[taskId].tDisplayedMonId; struct HallofFameMon* currMon = &sHofMonPtr->mon[currMonId]; - if (gTasks[taskId].tMonNumber > 3) + if (gTasks[taskId].tMonNumber > PARTY_SIZE / 2) { xPos = sHallOfFame_MonFullTeamPositions[currMonId][0]; yPos = sHallOfFame_MonFullTeamPositions[currMonId][1]; @@ -893,7 +893,7 @@ static void Task_HofPC_DrawSpritesPrintText(u8 taskId) u16 spriteId; s16 posX, posY; - if (gTasks[taskId].tMonNo > 3) + if (gTasks[taskId].tMonNo > PARTY_SIZE / 2) { posX = sHallOfFame_MonFullTeamPositions[i][2]; posY = sHallOfFame_MonFullTeamPositions[i][3]; diff --git a/src/item_use.c b/src/item_use.c index f54e690b4..12c89b287 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -222,9 +222,9 @@ void ItemUseOutOfBattle_Bike(u8 taskId) static void ItemUseOnFieldCB_Bike(u8 taskId) { if (!ItemId_GetSecondaryId(gSpecialVar_ItemId)) - GetOnOffBike(2); + GetOnOffBike(PLAYER_AVATAR_FLAG_MACH_BIKE); else - GetOnOffBike(4); + GetOnOffBike(PLAYER_AVATAR_FLAG_ACRO_BIKE); ScriptUnfreezeObjectEvents(); ScriptContext2_Disable(); DestroyTask(taskId); diff --git a/src/map_name_popup.c b/src/map_name_popup.c index 2010cea59..32da4d0b4 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/minigame_countdown.c b/src/minigame_countdown.c new file mode 100644 index 000000000..be1c42e29 --- /dev/null +++ b/src/minigame_countdown.c @@ -0,0 +1,636 @@ +#include "global.h" +#include "decompress.h" +#include "link.h" +#include "link_rfu.h" +#include "sound.h" +#include "task.h" +#include "trig.h" +#include "constants/songs.h" + +extern const struct OamData gOamData_AffineOff_ObjNormal_32x32; + +static void sub_802E6D0(u8 taskId); +static void sub_802E83C(u8 taskId); +static void sub_802E8C8(u8 taskId); +static void sub_802EA50(u8 taskId); +static void sub_802EAB0(u8 taskId); +static void sub_802EB98(u8 taskId); +static void Task_MinigameCountdown(u8 taskId); +static bool32 RunMinigameCountdownDigitsAnim(u8 spriteId); +static bool32 IsStartGraphicAnimRunning(u8 spriteId); +static void Load321StartGfx(u16 tileTag, u16 palTag); +static u8 CreateNumberSprite(u16 tileTag, u16 palTag, s16 x, s16 y, u8 subpriority); +static void CreateStartSprite(u16 tileTag, u16 palTag, s16 x, s16 y, u8 subpriority, s16 *spriteId1, s16 *spriteId2); +static void InitStartGraphic(u8 spriteId1, u8 spriteId2, u8 spriteId3); +static void SpriteCB_Start(struct Sprite *sprite); + +static const u16 sSpritePal_321Start_2[] = INCBIN_U16("graphics/link_games/321start_2.gbapal"); +static const u32 sSpriteSheet_321Start_2[] = INCBIN_U32("graphics/link_games/321start_2.4bpp.lz"); + +static const struct CompressedSpriteSheet gUnknown_082FE6C8[] = +{ + {sSpriteSheet_321Start_2, 0xC00, 0x2000}, + {}, +}; + +static const struct SpritePalette gUnknown_082FE6D8[] = +{ + {sSpritePal_321Start_2, 0x2000}, + {}, +}; + +static const union AnimCmd sSpriteAnim_82FE6E8[] = +{ + ANIMCMD_FRAME(0, 0), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_82FE6F0[] = +{ + ANIMCMD_FRAME(16, 0), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_82FE6F8[] = +{ + ANIMCMD_FRAME(32, 0), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_82FE700[] = +{ + ANIMCMD_FRAME(64, 0), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_82FE708[] = +{ + ANIMCMD_FRAME(48, 0), + ANIMCMD_END +}; + +static const union AnimCmd sSpriteAnim_82FE710[] = +{ + ANIMCMD_FRAME(80, 0), + ANIMCMD_END +}; + +static const union AnimCmd *const sSpriteAnimTable_82FE718[] = +{ + sSpriteAnim_82FE6E8, + sSpriteAnim_82FE6F0, + sSpriteAnim_82FE6F8, + sSpriteAnim_82FE700, + sSpriteAnim_82FE708, + sSpriteAnim_82FE710 +}; + +static const struct SpriteTemplate gUnknown_082FE730[] = +{ + { + .tileTag = 0x2000, + .paletteTag = 0x2000, + .oam = &gOamData_AffineOff_ObjNormal_32x32, + .anims = sSpriteAnimTable_82FE718, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }, +}; + +static const TaskFunc gUnknown_082FE748[][4] = +{ + { + sub_802E83C, + sub_802E8C8, + sub_802EA50, + sub_802EAB0 + }, +}; + +static const u16 sSpritePal_321Start[] = INCBIN_U16("graphics/link_games/321start.gbapal"); +static const u32 sSpriteSheet_321Start[] = INCBIN_U32("graphics/link_games/321start.4bpp.lz"); + +// Unused +static u32 sub_802E63C(u8 funcSetId, u8 taskPriority) +{ + u8 taskId = CreateTask(sub_802E6D0, taskPriority); + struct Task *task = &gTasks[taskId]; + + task->data[0] = 1; + task->data[1] = funcSetId; + gUnknown_082FE748[funcSetId][0](taskId); + return taskId; +} + +static bool32 sub_802E688(void) +{ + u8 taskId = FindTaskIdByFunc(sub_802E6D0); + if (taskId == 0xFF) + return FALSE; + + gTasks[taskId].data[0] = 2; + return TRUE; +} + +static bool32 sub_802E6BC(void) +{ + return FuncIsActiveTask(sub_802E6D0); +} + +static void sub_802E6D0(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + switch (data[0]) + { + case 2: + gUnknown_082FE748[data[1]][2](taskId); + data[0] = 3; + break; + case 3: + gUnknown_082FE748[data[1]][3](taskId); + break; + case 4: + gUnknown_082FE748[data[1]][1](taskId); + DestroyTask(taskId); + break; + } +} + +static void sub_802E75C(u8 taskId, s16 *data) +{ + u8 i; + struct Sprite *sprite; + + LoadCompressedSpriteSheet(&gUnknown_082FE6C8[data[3]]); + LoadSpritePalette(&gUnknown_082FE6D8[data[4]]); + for (i = 0; i < data[8]; i++) + data[13 + i] = CreateSprite(&gUnknown_082FE730[data[2]], data[9], data[10], data[7]); + for (i = 0; i < data[8]; i++) + { + sprite = &gSprites[data[13 + i]]; + sprite->oam.priority = data[6]; + sprite->invisible = TRUE; + sprite->data[1] = data[5]; + sprite->data[3] = taskId; + sprite->data[4] = i; + sprite->data[5] = data[13]; + } +} + +static void sub_802E83C(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + data[2] = 0; + data[3] = 0; + data[4] = 0; + data[5] = 60; + data[6] = 0; + data[7] = 0; + data[8] = 3; + data[9] = 120; + data[10] = 88; + sub_802E75C(taskId, data); + + StartSpriteAnim(&gSprites[data[14]], 4); + gSprites[data[14]].pos2.x = -32; + + StartSpriteAnim(&gSprites[data[15]], 5); + gSprites[data[15]].pos2.x = 32; +} + +static void sub_802E8C8(u8 taskId) +{ + u8 i = 0; + s16 *data = gTasks[taskId].data; + + for (i = 0; i < data[8]; i++) + DestroySprite(&gSprites[data[13 + i]]); + FreeSpriteTilesByTag(gUnknown_082FE6C8[data[3]].tag); + FreeSpritePaletteByTag(gUnknown_082FE6D8[data[4]].tag); +} + +static void sub_802E938(struct Sprite *sprite) +{ + s16 *data = gTasks[sprite->data[3]].data; + + if (data[11] % data[5] != 0) + return; + if (data[11] == data[10]) + return; + + data[10] = data[11]; + switch (sprite->data[2]) + { + case 0: + sprite->invisible = FALSE; + case 1: + case 2: + PlaySE(SE_KON); + StartSpriteAnim(sprite, sprite->data[2]); + break; + case 3: + PlaySE(SE_PIN); + StartSpriteAnim(sprite, sprite->data[2]); + gSprites[data[14]].invisible = FALSE; + gSprites[data[15]].invisible = FALSE; + break; + case 4: + sprite->invisible = TRUE; + gSprites[data[14]].invisible = TRUE; + gSprites[data[15]].invisible = TRUE; + data[0] = 4; + return; + } + sprite->data[2]++; +} + +static void sub_802EA50(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + PlaySE(SE_KON); + gSprites[data[13]].callback = sub_802E938; + gSprites[data[13]].invisible = FALSE; + gTasks[taskId].data[0] = 3; +} + +static void sub_802EAB0(u8 taskId) +{ + u16 packet[6]; + s16 *data = gTasks[taskId].data; + + if (gReceivedRemoteLinkPlayers != 0) + { + if (gRecvCmds[0][1] == 0x7FFF) + data[11] = gRecvCmds[0][2]; + if (GetMultiplayerId() == 0) + { + data[12]++; + memset(packet, 0, sizeof(packet)); + packet[0] = 0x7FFF; + packet[1] = data[12]; + sub_800FE50(packet); + } + } + else + { + data[11]++; + } +} + +#define tState data[0] +#define tTilesTag data[2] +#define tPalTag data[3] +#define tX data[4] +#define tY data[5] +#define tSubpriority data[6] +#define tSpriteId1 data[7] +#define tSpriteId2 data[8] +#define tSpriteId3 data[9] + +void StartMinigameCountdown(s16 tilesTag, s16 palTag, s16 x, s16 y, u8 subpriority) +{ + u8 taskId = CreateTask(Task_MinigameCountdown, 80); + gTasks[taskId].tTilesTag = tilesTag; + gTasks[taskId].tPalTag = palTag; + gTasks[taskId].tX = x; + gTasks[taskId].tY = y; + gTasks[taskId].tSubpriority = subpriority; +} + +bool32 IsMinigameCountdownRunning(void) +{ + return FuncIsActiveTask(Task_MinigameCountdown); +} + +static void Task_MinigameCountdown(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + switch (tState) + { + case 0: + Load321StartGfx(tTilesTag, tPalTag); + tSpriteId1 = CreateNumberSprite(tTilesTag, tPalTag, tX, tY, tSubpriority); + CreateStartSprite(tTilesTag, tPalTag, tX, tY, tSubpriority, &tSpriteId2, &tSpriteId3); + tState++; + break; + case 1: + if (!RunMinigameCountdownDigitsAnim(tSpriteId1)) + { + InitStartGraphic(tSpriteId1, tSpriteId2, tSpriteId3); + FreeSpriteOamMatrix(&gSprites[tSpriteId1]); + DestroySprite(&gSprites[tSpriteId1]); + tState++; + } + break; + case 2: + if (!IsStartGraphicAnimRunning(tSpriteId2)) + { + DestroySprite(&gSprites[tSpriteId2]); + DestroySprite(&gSprites[tSpriteId3]); + FreeSpriteTilesByTag(tTilesTag); + FreeSpritePaletteByTag(tPalTag); + DestroyTask(taskId); + } + break; + } +} + +static bool32 RunMinigameCountdownDigitsAnim(u8 spriteId) +{ + struct Sprite *sprite = &gSprites[spriteId]; + + switch (sprite->data[0]) + { + case 0: + sub_8007E18(sprite, 0x800, 0x1A); + sprite->data[0]++; + // fallthrough + case 1: + if (sprite->data[2] == 0) + PlaySE(SE_KON2); + if (++sprite->data[2] >= 20) + { + sprite->data[2] = 0; + StartSpriteAffineAnim(sprite, 1); + sprite->data[0]++; + } + break; + case 2: + if (sprite->affineAnimEnded) + sprite->data[0]++; + break; + case 3: + if (++sprite->data[2] >= 4) + { + sprite->data[2] = 0; + sprite->data[0]++; + StartSpriteAffineAnim(sprite, 2); + } + break; + case 4: + sprite->pos1.y -= 4; + if (++sprite->data[2] >= 8) + { + if (sprite->data[4] <= 1) + { + StartSpriteAnim(sprite, sprite->data[4] + 1); + sprite->data[2] = 0; + sprite->data[0]++; + } + else + { + sprite->data[0] = 7; + return FALSE; + } + } + break; + case 5: + sprite->pos1.y += 4; + if (++sprite->data[2] >= 8) + { + sprite->data[2] = 0; + StartSpriteAffineAnim(sprite, 3); + sprite->data[0]++; + } + break; + case 6: + if (sprite->affineAnimEnded) + { + sprite->data[4]++; + sprite->data[0] = 1; + } + break; + case 7: + return FALSE; + } + + return TRUE; +} + +// First argument is unused. +static void InitStartGraphic(u8 spriteId1, u8 spriteId2, u8 spriteId3) +{ + gSprites[spriteId2].pos2.y = -40; + gSprites[spriteId3].pos2.y = -40; + gSprites[spriteId2].invisible = FALSE; + gSprites[spriteId3].invisible = FALSE; + gSprites[spriteId2].callback = SpriteCB_Start; + gSprites[spriteId3].callback = SpriteCB_Start; +} + +static bool32 IsStartGraphicAnimRunning(u8 spriteId) +{ + return gSprites[spriteId].callback == SpriteCB_Start; +} + +static void SpriteCB_Start(struct Sprite *sprite) +{ + int y; + s16 *data = sprite->data; + + switch (data[0]) + { + case 0: + data[4] = 64; + data[5] = sprite->pos2.y << 4; + data[0]++; + case 1: + data[5] += data[4]; + data[4]++; + sprite->pos2.y = data[5] >> 4; + if (sprite->pos2.y >= 0) + { + PlaySE(SE_KON2); + sprite->pos2.y = 0; + data[0]++; + } + break; + case 2: + data[1] += 12; + if (data[1] >= 128) + { + PlaySE(SE_KON2); + data[1] = 0; + data[0]++; + } + y = gSineTable[data[1]]; + sprite->pos2.y = -(y >> 4); + break; + case 3: + data[1] += 16; + if (data[1] >= 128) + { + PlaySE(SE_KON2); + data[1] = 0; + data[0]++; + } + sprite->pos2.y = -(gSineTable[data[1]] >> 5); + break; + case 4: + if (++data[1] > 40) + sprite->callback = SpriteCallbackDummy; + break; + } +} + +static void Load321StartGfx(u16 tileTag, u16 palTag) +{ + struct CompressedSpriteSheet spriteSheet = {sSpriteSheet_321Start, 0xE00, 0}; + struct SpritePalette spritePalette = {sSpritePal_321Start, 0}; + + spriteSheet.tag = tileTag; + spritePalette.tag = palTag; + + LoadCompressedSpriteSheet(&spriteSheet); + LoadSpritePalette(&spritePalette); +} + +static const struct OamData sOamData_Numbers = +{ + .y = 0, + .affineMode = ST_OAM_AFFINE_DOUBLE, + .objMode = ST_OAM_OBJ_NORMAL, + .mosaic = 0, + .bpp = ST_OAM_4BPP, + .shape = SPRITE_SHAPE(32x32), + .x = 0, + .matrixNum = 0, + .size = SPRITE_SIZE(32x32), + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0 +}; + +static const struct OamData sOamData_Start = +{ + .y = 0, + .affineMode = ST_OAM_AFFINE_OFF, + .objMode = ST_OAM_OBJ_NORMAL, + .mosaic = 0, + .bpp = ST_OAM_4BPP, + .shape = SPRITE_SHAPE(64x32), + .x = 0, + .matrixNum = 0, + .size = SPRITE_SIZE(64x32), + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0 +}; + +static const union AnimCmd sAnim_Numbers_Three[] = +{ + ANIMCMD_FRAME(0, 1), + ANIMCMD_END +}; + +static const union AnimCmd sAnim_Numbers_Two[] = +{ + ANIMCMD_FRAME(16, 1), + ANIMCMD_END +}; + +static const union AnimCmd sAnim_Numbers_One[] = +{ + ANIMCMD_FRAME(32, 1), + ANIMCMD_END +}; + +static const union AnimCmd *const sAnimTable_Numbers[] = +{ + sAnim_Numbers_Three, + sAnim_Numbers_Two, + sAnim_Numbers_One +}; + +static const union AnimCmd sAnim_StartLeft[] = +{ + ANIMCMD_FRAME(48, 1), + ANIMCMD_END +}; + +static const union AnimCmd sAnim_StartRight[] = +{ + ANIMCMD_FRAME(80, 1), + ANIMCMD_END +}; + +static const union AnimCmd *const sAnimTable_Start[] = +{ + sAnim_StartLeft, + sAnim_StartRight +}; + +static const union AffineAnimCmd sAffineAnim_Numbers_0[] = +{ + AFFINEANIMCMD_FRAME(256, 256, 0, 0), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sAffineAnim_Numbers_1[] = +{ + AFFINEANIMCMD_FRAME(256, 256, 0, 0), + AFFINEANIMCMD_FRAME(16, -16, 0, 8), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sAffineAnim_Numbers_2[] = +{ + AFFINEANIMCMD_FRAME(-18, 18, 0, 8), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sAffineAnim_Numbers_3[] = +{ + AFFINEANIMCMD_FRAME( 6, -6, 0, 8), + AFFINEANIMCMD_FRAME( -4, 4, 0, 8), + AFFINEANIMCMD_FRAME(256, 256, 0, 0), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd *const sAffineAnimTable_Numbers[] = +{ + sAffineAnim_Numbers_0, + sAffineAnim_Numbers_1, + sAffineAnim_Numbers_2, + sAffineAnim_Numbers_3 +}; + +static u8 CreateNumberSprite(u16 tileTag, u16 palTag, s16 x, s16 y, u8 subpriority) +{ + struct SpriteTemplate spriteTemplate = + { + .oam = &sOamData_Numbers, + .anims = sAnimTable_Numbers, + .affineAnims = sAffineAnimTable_Numbers, + .callback = SpriteCallbackDummy, + }; + + spriteTemplate.tileTag = tileTag; + spriteTemplate.paletteTag = palTag; + return CreateSprite(&spriteTemplate, x, y, subpriority); +} + +static void CreateStartSprite(u16 tileTag, u16 palTag, s16 x, s16 y, u8 subpriority, s16 *spriteId1, s16 *spriteId2) +{ + struct SpriteTemplate spriteTemplate = + { + .oam = &sOamData_Start, + .anims = sAnimTable_Start, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy, + }; + + spriteTemplate.tileTag = tileTag; + spriteTemplate.paletteTag = palTag; + *spriteId1 = CreateSprite(&spriteTemplate, x - 32, y, subpriority); + *spriteId2 = CreateSprite(&spriteTemplate, x + 32, y, subpriority); + + gSprites[*spriteId1].invisible = TRUE; + gSprites[*spriteId2].invisible = TRUE; + StartSpriteAnim(&gSprites[*spriteId2], 1); +} diff --git a/src/party_menu.c b/src/party_menu.c index d7cb1d720..875c70bba 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -152,7 +152,7 @@ EWRAM_DATA u8 gSelectedMonPartyId = 0; EWRAM_DATA MainCallback gPostMenuFieldCallback = NULL; static EWRAM_DATA u16 *sSlot1TilemapBuffer = 0; // for switching party slots static EWRAM_DATA u16 *sSlot2TilemapBuffer = 0; // -EWRAM_DATA u8 gSelectedOrderFromParty[4] = {0}; +EWRAM_DATA u8 gSelectedOrderFromParty[MAX_FRONTIER_PARTY_SIZE] = {0}; static EWRAM_DATA u16 sPartyMenuItemId = 0; static EWRAM_DATA u16 sUnused_0203CEFE = 0; EWRAM_DATA u8 gBattlePartyCurrentOrder[PARTY_SIZE / 2] = {0}; // bits 0-3 are the current pos of Slot 1, 4-7 are Slot 2, and so on @@ -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: @@ -5624,9 +5624,9 @@ static u8 GetMaxBattleEntries(void) switch (VarGet(VAR_FRONTIER_FACILITY)) { case FACILITY_MULTI_OR_EREADER: - return 3; + return MULTI_PARTY_SIZE; case FACILITY_UNION_ROOM: - return 2; + return UNION_ROOM_PARTY_SIZE; default: // Battle Frontier return gSpecialVar_0x8005; } @@ -5639,7 +5639,7 @@ static u8 GetMinBattleEntries(void) case FACILITY_MULTI_OR_EREADER: return 1; case FACILITY_UNION_ROOM: - return 2; + return UNION_ROOM_PARTY_SIZE; default: // Battle Frontier return gSpecialVar_0x8005; } @@ -6074,7 +6074,7 @@ static void Task_MultiPartnerPartySlideIn(u8 taskId) SlideMultiPartyMenuBoxSpritesOneStep(taskId); if (tXPos == 0) { - for (i = 3; i < PARTY_SIZE; i++) + for (i = MULTI_PARTY_SIZE; i < PARTY_SIZE; i++) { if (gMultiPartnerParty[i - MULTI_PARTY_SIZE].species != SPECIES_NONE) AnimateSelectedPartyIcon(sPartyMenuBoxes[i].monSpriteId, 0); diff --git a/src/pokedex.c b/src/pokedex.c index bd766fbf7..080548553 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -30,48 +30,123 @@ #include "constants/songs.h" #include "constants/species.h" +enum +{ + PAGE_MAIN, + PAGE_INFO, + PAGE_SEARCH, + PAGE_SEARCH_RESULTS, + PAGE_UNK, + PAGE_AREA, + PAGE_CRY, + PAGE_SIZE +}; + +enum +{ + AREA_SCREEN, + CRY_SCREEN, + SIZE_SCREEN, + CANCEL_SCREEN, + SCREEN_COUNT +}; + +enum +{ + SEARCH_NAME, + SEARCH_COLOR, + SEARCH_TYPE_LEFT, + SEARCH_TYPE_RIGHT, + SEARCH_ORDER, + SEARCH_MODE, + SEARCH_OK, + SEARCH_COUNT +}; + +enum +{ + SEARCH_TOPBAR_SEARCH, + SEARCH_TOPBAR_SHIFT, + SEARCH_TOPBAR_CANCEL, + SEARCH_TOPBAR_COUNT +}; + +enum +{ + ORDER_NUMERICAL, + ORDER_ALPHABETICAL, + ORDER_HEAVIEST, + ORDER_LIGHTEST, + ORDER_TALLEST, + ORDER_SMALLEST +}; + +enum +{ + NAME_ABC = 1, + NAME_DEF, + NAME_GHI, + NAME_JKL, + NAME_MNO, + NAME_PQR, + NAME_STU, + NAME_VWX, + NAME_YZ, +}; + +// For scrolling search parameter +#define MAX_SEARCH_PARAM_ON_SCREEN 6 +#define MAX_SEARCH_PARAM_CURSOR_POS (MAX_SEARCH_PARAM_ON_SCREEN - 1) + +#define MAX_MONS_ON_SCREEN 4 + +#define LIST_SCROLL_STEP 16 + +#define POKEBALL_ROTATION_TOP 64 +#define POKEBALL_ROTATION_BOTTOM (POKEBALL_ROTATION_TOP - 16) + // EWRAM static EWRAM_DATA struct PokedexView *sPokedexView = NULL; -static EWRAM_DATA u16 gUnknown_02039B50 = 0; -static EWRAM_DATA u8 gUnknown_02039B52 = 0; +static EWRAM_DATA u16 sLastSelectedPokemon = 0; +static EWRAM_DATA u8 sPokeBallRotation = 0; static EWRAM_DATA struct PokedexListItem *sPokedexListItem = NULL; // IWRAM common // This is written to, but never read. u8 gUnusedPokedexU8; -void (*gUnknown_030060B4)(void); +void (*gPokedexVBlankCB)(void); -struct PokedexOption +struct SearchOptionText { const u8 *description; const u8 *title; }; -struct UnknownStruct1 +struct SearchOption { - const struct PokedexOption *pokedexList; - u8 unk4; - u8 unk5; + const struct SearchOptionText *texts; + u8 taskDataCursorPos; + u8 taskDataScrollOffset; u16 numOptions; }; -struct UnknownStruct3 +struct SearchMenuTopBarItem { - const u8 *text; - u8 unk4; - u8 unk5; - u8 unk6; + const u8 *description; + u8 highlightX; + u8 highlightY; + u8 highlightWidth; }; -struct UnknownStruct4 +struct SearchMenuItem { - const u8 *text; - u8 unk4; - u8 unk5; - u8 unk6; - u8 unk7; - u8 unk8; - u8 unk9; + const u8 *description; + u8 titleBgX; + u8 titleBgY; + u8 titleBgWidth; + u8 selectionBgX; + u8 selectionBgY; + u8 selectionBgWidth; }; extern struct MusicPlayerInfo gMPlayInfo_BGM; @@ -85,163 +160,151 @@ struct PokedexListItem struct PokedexView { - struct PokedexListItem pokedexList[NATIONAL_DEX_COUNT]; - u16 unk608; - u8 unk60A_1:1; - u8 unk60A_2:1; - u8 unk60B; + struct PokedexListItem pokedexList[NATIONAL_DEX_COUNT + 1]; u16 pokemonListCount; u16 selectedPokemon; - u16 unk610; + u16 selectedPokemonBackup; u16 dexMode; - u16 unk614; + u16 dexModeBackup; u16 dexOrder; - u16 unk618; + u16 dexOrderBackup; u16 seenCount; u16 ownCount; - u16 monSpriteIds[4]; + u16 monSpriteIds[MAX_MONS_ON_SCREEN]; u16 selectedMonSpriteId; - u16 unk628; - u16 unk62A; - u8 unk62C; + u16 pokeBallRotationStep; + u16 pokeBallRotationBackup; + u8 pokeBallRotation; u8 initialVOffset; - u8 unk62E; - u8 unk62F; - s16 unk630; - s16 unk632; - u16 unk634; - u16 unk636; - u16 unk638; - u16 unk63A[4]; - u8 filler642[8]; - u8 unk64A; - u8 unk64B; - u8 unk64C_1:1; + u8 scrollTimer; + u8 scrollDirection; + s16 listVOffset; + s16 listMovingVOffset; + u16 scrollMonIncrement; + u16 maxScrollTimer; + u16 scrollSpeed; + u16 unkArr1[4]; // Cleared, never read + u8 filler[8]; + u8 currentPage; + u8 currentPageBackup; + bool8 isSearchResults:1; u8 selectedScreen; - u8 unk64E; - u8 menuIsOpen; //menuIsOpen - u16 menuCursorPos; //Menu cursor position + u8 screenSwitchState; + u8 menuIsOpen; + u16 menuCursorPos; s16 menuY; //Menu Y position (inverted because we use REG_BG0VOFS for this) - u8 unk654[8]; - u8 unk65C[8]; -}; - -enum -{ - AREA_SCREEN, - CRY_SCREEN, - SIZE_SCREEN, - CANCEL_SCREEN, + u8 unkArr2[8]; // Cleared, never read + u8 unkArr3[8]; // Cleared, never read }; // this file's functions -void sub_80BB774(void); -void sub_80BB78C(u8); -void sub_80BB7D4(u8); -void sub_80BBA28(u8); -void sub_80BBA78(u8); -void LoadPageOnceMonFinishedMoving(u8); -void sub_80BBC74(u8); -void sub_80BBD1C(u8); -void sub_80BBDE8(u8); -void sub_80BBE70(u8); -void sub_80BBEB8(u8); -void sub_80BC0A8(u8); -static void HandleButtonPress_StartMenu(u8); -void sub_80BC2D4(u8); -void sub_80BC360(u8); -void sub_80BC3DC(u8); -void sub_80BC47C(u8); -bool8 sub_80BC514(u8); -static void LoadPokedexBgPalette(u8); +static void CB2_Pokedex(void); +static void Task_OpenPokedexMainPage(u8); +static void Task_HandlePokedexInput(u8); +static void Task_WaitForScroll(u8); +static void Task_HandlePokedexStartMenuInput(u8); +static void Task_OpenInfoScreenAfterMonMovement(u8); +static void Task_WaitForExitInfoScreen(u8); +static void Task_WaitForExitSearch(u8); +static void Task_ClosePokedex(u8); +static void Task_OpenSearchResults(u8); +static void Task_HandleSearchResultsInput(u8); +static void Task_WaitForSearchResultsScroll(u8); +static void Task_HandleSearchResultsStartMenuInput(u8); +static void Task_OpenSearchResultsInfoScreenAfterMonMovement(u8); +static void Task_WaitForExitSearchResultsInfoScreen(u8); +static void Task_ReturnToPokedexFromSearchResults(u8); +static void Task_ClosePokedexFromSearchResultsStartMenu(u8); +static bool8 LoadPokedexListPage(u8); +static void LoadPokedexBgPalette(bool8); static void FreeWindowAndBgBuffers(void); -static void CreatePokedexList(u8 dexMode, u8 sortMode); +static void CreatePokedexList(u8, u8); static void CreateMonDexNum(u16, u8, u8, u16); static void CreateCaughtBall(u16, u8, u8, u16); static u8 CreateMonName(u16, u8, u8); static void ClearMonListEntry(u8 x, u8 y, u16 unused); -static void CreateInitialPokemonSprites(u16, u16); -bool8 sub_80BD404(u8, u8, u8); -u16 sub_80BD69C(u16, u16); +static void CreateMonSpritesAtPos(u16, u16); +static bool8 UpdateDexListScroll(u8, u8, u8); +static u16 TryDoPokedexScroll(u16, u16); static void UpdateSelectedMonSpriteId(void); -static bool8 UpdateSelectedMon(void); +static bool8 TryDoInfoScreenScroll(void); static u8 ClearMonSprites(void); -u16 GetPokemonSpriteToDisplay(u16); -u32 sub_80BDACC(u16, s16, s16); +static u16 GetPokemonSpriteToDisplay(u16); +static u32 CreatePokedexMonSprite(u16, s16, s16); static void CreateInterfaceSprites(u8); -void MoveMonIntoPosition(struct Sprite *sprite); +static void SpriteCB_MoveMonForInfoScreen(struct Sprite *sprite); static void SpriteCB_Scrollbar(struct Sprite *sprite); -void sub_80BE658(struct Sprite *sprite); -void sub_80BE758(struct Sprite *sprite); -void sub_80BE780(struct Sprite *sprite); -void sub_80BE44C(struct Sprite *sprite); -void sub_80BE834(struct Sprite *sprite); -void sub_80BE4E0(struct Sprite *sprite); -u8 SetupInfoScreen(struct PokedexListItem*, u8 monSpriteId); -bool8 sub_80BE9C4(u8); -u8 sub_80BE9F8(struct PokedexListItem*, u8); -void LoadInfoScreen(u8); -void ChangePokedexScreen(u8); -void LoadSelectedScreen(u8); -void BeginChangeInfoScreen(u8); -void BeginReturnToPokedex(u8); -void LoadAreaScreen(u8); -static void WaitForAreaScreenInput(u8 taskId); -void sub_80BF1EC(u8); -void LoadCryScreen(u8); -void sub_80BF5CC(u8); -void sub_80BF790(u8); -void sub_80BF7FC(u8); -void LoadSizeScreen(u8); -void sub_80BFBB0(u8); -void sub_80BFC78(u8); -void sub_80BFCDC(u16); -void sub_80BFCF4(u16); -void sub_80BFD0C(u8, u16); -void sub_80BFD7C(u8, u16); -static void Task_DisplayNewMonData(u8); -void sub_80C0088(u8); -void blockset_load_palette_to_gpu(u8); -void sub_80C01CC(struct Sprite *sprite); +static void SpriteCB_ScrollArrow(struct Sprite *sprite); +static void SpriteCB_DexListInterfaceText(struct Sprite *sprite); +static void SpriteCB_RotatingPokeBall(struct Sprite *sprite); +static void SpriteCB_SeenOwnInfo(struct Sprite *sprite); +static void SpriteCB_DexListStartMenuCursor(struct Sprite *sprite); +static void SpriteCB_PokedexListMonSprite(struct Sprite *sprite); +static u8 LoadInfoScreen(struct PokedexListItem*, u8 monSpriteId); +static bool8 IsInfoScreenScrolling(u8); +static u8 sub_80BE9F8(struct PokedexListItem*, u8); +static void Task_LoadInfoScreen(u8); +static void Task_HandleInfoScreenInput(u8); +static void Task_SwitchScreensFromInfoScreen(u8); +static void Task_LoadInfoScreenWaitForFade(u8); +static void Task_ExitInfoScreen(u8); +static void Task_LoadAreaScreen(u8); +static void Task_WaitForAreaScreenInput(u8 taskId); +static void Task_SwitchScreensFromAreaScreen(u8); +static void Task_LoadCryScreen(u8); +static void Task_HandleCryScreenInput(u8); +static void Task_SwitchScreensFromCryScreen(u8); +static void LoadPlayArrowPalette(bool8); +static void Task_LoadSizeScreen(u8); +static void Task_HandleSizeScreenInput(u8); +static void Task_SwitchScreensFromSizeScreen(u8); +static void LoadScreenSelectBarMain(u16); +static void LoadScreenSelectBarSubmenu(u16); +static void HighlightScreenSelectBarItem(u8, u16); +static void HighlightSubmenuScreenSelectBarItem(u8, u16); +static void Task_DisplayCaughtMonDexPage(u8); +static void Task_HandleCaughtMonPageInput(u8); +static void Task_ExitCaughtMonPage(u8); +static void SpriteCB_SlideCaughtMonToCenter(struct Sprite *sprite); static void PrintMonInfo(u32 num, u32, u32 owned, u32 newEntry); static void PrintMonHeight(u16 height, u8 left, u8 top); static void PrintMonWeight(u16 weight, u8 left, u8 top); static void ResetOtherVideoRegisters(u16); -u8 sub_80C0B44(u8, u16, u8, u8); +static u8 PrintCryScreenSpeciesName(u8, u16, u8, u8); static void PrintFootprint(u8 windowId, u16 dexNum); -u16 sub_80C0EF8(u16, s16, s16, s8); -u16 sub_80C0E0C(u8, u16, u16, u16); -u8 LoadSearchMenu(void); -void Task_LoadSearchMenu(u8); -void sub_80C1570(u8); -void sub_80C15B0(u8); -void sub_80C16CC(u8); -void sub_80C170C(u8); -void sub_80C19A4(u8); -void sub_80C1A4C(u8); -void sub_80C1AB8(u8); -void sub_80C1B64(u8); -void sub_80C1BCC(u8); -void sub_80C1D38(u8); -void sub_80C1D70(u8); -void sub_80C2040(u8); -void sub_80C2064(u8, u8); -void sub_80C20F8(u8); -void sub_80C21D4(u8); -void sub_80C2294(u8); +static u16 CreateSizeScreenTrainerPic(u16, s16, s16, s8); +static u16 GetNextPosition(u8, u16, u16, u16); +static u8 LoadSearchMenu(void); +static void Task_LoadSearchMenu(u8); +static void Task_SwitchToSearchMenuTopBar(u8); +static void Task_HandleSearchTopBarInput(u8); +static void Task_SwitchToSearchMenu(u8); +static void Task_HandleSearchMenuInput(u8); +static void Task_StartPokedexSearch(u8); +static void Task_WaitAndCompleteSearch(u8); +static void Task_SearchCompleteWaitForInput(u8); +static void Task_SelectSearchMenuItem(u8); +static void Task_HandleSearchParameterInput(u8); +static void Task_ExitSearch(u8); +static void Task_ExitSearchWaitForFade(u8); +static void HighlightSelectedSearchTopBarItem(u8); +static void HighlightSelectedSearchMenuItem(u8, u8); +static void PrintSelectedSearchParameters(u8); +static void DrawOrEraseSearchParameterBox(bool8); +static void PrintSearchParameterText(u8); static u8 GetSearchModeSelection(u8 taskId, u8 option); -void sub_80C23B8(u8); -void sub_80C2594(u8); -void sub_80C2618(const u8*); -void sub_80C2638(u32); -void sub_80C2650(u32); -void sub_80C2668(u32, const u8*); -void sub_80C267C(void); +static void SetDefaultSearchModeAndOrder(u8); +static void CreateSearchParameterScrollArrows(u8); +static void EraseAndPrintSearchTextBox(const u8*); +static void EraseSelectorArrow(u32); +static void PrintSelectorArrow(u32); +static void PrintSearchParameterTitle(u32, const u8*); +static void ClearSearchParameterBoxText(void); // const rom data #include "data/pokemon/pokedex_orders.h" -static const struct OamData sOamData_855CFE4 = +static const struct OamData sOamData_ScrollBar = { .y = 160, .affineMode = ST_OAM_AFFINE_OFF, @@ -258,7 +321,7 @@ static const struct OamData sOamData_855CFE4 = .affineParam = 0 }; -static const struct OamData sOamData_855CFEC = +static const struct OamData sOamData_ScrollArrow = { .y = 160, .affineMode = ST_OAM_AFFINE_OFF, @@ -275,7 +338,7 @@ static const struct OamData sOamData_855CFEC = .affineParam = 0 }; -static const struct OamData sOamData_855CFF4 = +static const struct OamData sOamData_InterfaceText = { .y = 160, .affineMode = ST_OAM_AFFINE_OFF, @@ -292,7 +355,7 @@ static const struct OamData sOamData_855CFF4 = .affineParam = 0 }; -static const struct OamData sOamData_855CFFC = +static const struct OamData sOamData_RotatingPokeBall = { .y = 160, .affineMode = ST_OAM_AFFINE_OFF, @@ -309,7 +372,7 @@ static const struct OamData sOamData_855CFFC = .affineParam = 0 }; -static const struct OamData sOamData_855D004 = +static const struct OamData sOamData_SeenOwnText = { .y = 160, .affineMode = ST_OAM_AFFINE_OFF, @@ -326,7 +389,7 @@ static const struct OamData sOamData_855D004 = .affineParam = 0 }; -static const struct OamData sOamData_855D00C = +static const struct OamData sOamData_Dex8x16 = { .y = 160, .affineMode = ST_OAM_AFFINE_OFF, @@ -343,379 +406,380 @@ static const struct OamData sOamData_855D00C = .affineParam = 0 }; -static const union AnimCmd sSpriteAnim_855D014[] = +static const union AnimCmd sSpriteAnim_ScrollBar[] = { ANIMCMD_FRAME(3, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D01C[] = +static const union AnimCmd sSpriteAnim_ScrollArrow[] = { ANIMCMD_FRAME(1, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D024[] = +static const union AnimCmd sSpriteAnim_RotatingPokeBall[] = { ANIMCMD_FRAME(16, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D02C[] = +static const union AnimCmd sSpriteAnim_StartButton[] = { ANIMCMD_FRAME(48, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D034[] = +static const union AnimCmd sSpriteAnim_SearchText[] = { ANIMCMD_FRAME(40, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D03C[] = +static const union AnimCmd sSpriteAnim_SelectButton[] = { ANIMCMD_FRAME(32, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D044[] = +static const union AnimCmd sSpriteAnim_MenuText[] = { ANIMCMD_FRAME(56, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D04C[] = +static const union AnimCmd sSpriteAnim_SeenText[] = { ANIMCMD_FRAME(64, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D054[] = +static const union AnimCmd sSpriteAnim_OwnText[] = { ANIMCMD_FRAME(96, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D05C[] = +static const union AnimCmd sSpriteAnim_HoennText[] = { ANIMCMD_FRAME(160, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D064[] = +static const union AnimCmd sSpriteAnim_NationalText[] = { ANIMCMD_FRAME(168, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D06C[] = +static const union AnimCmd sSpriteAnim_HoennSeenOwnDigit0[] = { ANIMCMD_FRAME(128, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D074[] = +static const union AnimCmd sSpriteAnim_HoennSeenOwnDigit1[] = { ANIMCMD_FRAME(130, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D07C[] = +static const union AnimCmd sSpriteAnim_HoennSeenOwnDigit2[] = { ANIMCMD_FRAME(132, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D084[] = +static const union AnimCmd sSpriteAnim_HoennSeenOwnDigit3[] = { ANIMCMD_FRAME(134, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D08C[] = +static const union AnimCmd sSpriteAnim_HoennSeenOwnDigit4[] = { ANIMCMD_FRAME(136, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D094[] = +static const union AnimCmd sSpriteAnim_HoennSeenOwnDigit5[] = { ANIMCMD_FRAME(138, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D09C[] = +static const union AnimCmd sSpriteAnim_HoennSeenOwnDigit6[] = { ANIMCMD_FRAME(140, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D0A4[] = +static const union AnimCmd sSpriteAnim_HoennSeenOwnDigit7[] = { ANIMCMD_FRAME(142, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D0AC[] = +static const union AnimCmd sSpriteAnim_HoennSeenOwnDigit8[] = { ANIMCMD_FRAME(144, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D0B4[] = +static const union AnimCmd sSpriteAnim_HoennSeenOwnDigit9[] = { ANIMCMD_FRAME(146, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D0BC[] = +static const union AnimCmd sSpriteAnim_NationalSeenOwnDigit0[] = { ANIMCMD_FRAME(176, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D0C4[] = +static const union AnimCmd sSpriteAnim_NationalSeenOwnDigit1[] = { ANIMCMD_FRAME(178, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D0CC[] = +static const union AnimCmd sSpriteAnim_NationalSeenOwnDigit2[] = { ANIMCMD_FRAME(180, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D0D4[] = +static const union AnimCmd sSpriteAnim_NationalSeenOwnDigit3[] = { ANIMCMD_FRAME(182, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D0DC[] = +static const union AnimCmd sSpriteAnim_NationalSeenOwnDigit4[] = { ANIMCMD_FRAME(184, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D0E4[] = +static const union AnimCmd sSpriteAnim_NationalSeenOwnDigit5[] = { ANIMCMD_FRAME(186, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D0EC[] = +static const union AnimCmd sSpriteAnim_NationalSeenOwnDigit6[] = { ANIMCMD_FRAME(188, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D0F4[] = +static const union AnimCmd sSpriteAnim_NationalSeenOwnDigit7[] = { ANIMCMD_FRAME(190, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D0FC[] = +static const union AnimCmd sSpriteAnim_NationalSeenOwnDigit8[] = { ANIMCMD_FRAME(192, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D104[] = +static const union AnimCmd sSpriteAnim_NationalSeenOwnDigit9[] = { ANIMCMD_FRAME(194, 30), ANIMCMD_END }; -static const union AnimCmd sSpriteAnim_855D10C[] = +static const union AnimCmd sSpriteAnim_DexListStartMenuCursor[] = { ANIMCMD_FRAME(4, 30), ANIMCMD_END }; -static const union AnimCmd *const sSpriteAnimTable_855D114[] = +static const union AnimCmd *const sSpriteAnimTable_ScrollBar[] = { - sSpriteAnim_855D014 + sSpriteAnim_ScrollBar }; -static const union AnimCmd *const sSpriteAnimTable_855D118[] = +static const union AnimCmd *const sSpriteAnimTable_ScrollArrow[] = { - sSpriteAnim_855D01C + sSpriteAnim_ScrollArrow }; -static const union AnimCmd *const sSpriteAnimTable_855D11C[] = +static const union AnimCmd *const sSpriteAnimTable_RotatingPokeBall[] = { - sSpriteAnim_855D024 + sSpriteAnim_RotatingPokeBall }; -static const union AnimCmd *const sSpriteAnimTable_855D120[] = +static const union AnimCmd *const sSpriteAnimTable_InterfaceText[] = { - sSpriteAnim_855D02C, - sSpriteAnim_855D034, - sSpriteAnim_855D03C, - sSpriteAnim_855D044 + sSpriteAnim_StartButton, + sSpriteAnim_SearchText, + sSpriteAnim_SelectButton, + sSpriteAnim_MenuText }; -static const union AnimCmd *const sSpriteAnimTable_855D130[] = +static const union AnimCmd *const sSpriteAnimTable_SeenOwnText[] = { - sSpriteAnim_855D04C, - sSpriteAnim_855D054 + sSpriteAnim_SeenText, + sSpriteAnim_OwnText }; -static const union AnimCmd *const sSpriteAnimTable_855D138[] = +static const union AnimCmd *const sSpriteAnimTable_HoennNationalText[] = { - sSpriteAnim_855D05C, - sSpriteAnim_855D064 + sSpriteAnim_HoennText, + sSpriteAnim_NationalText }; -static const union AnimCmd *const sSpriteAnimTable_855D140[] = +static const union AnimCmd *const sSpriteAnimTable_HoennSeenOwnNumber[] = { - sSpriteAnim_855D06C, - sSpriteAnim_855D074, - sSpriteAnim_855D07C, - sSpriteAnim_855D084, - sSpriteAnim_855D08C, - sSpriteAnim_855D094, - sSpriteAnim_855D09C, - sSpriteAnim_855D0A4, - sSpriteAnim_855D0AC, - sSpriteAnim_855D0B4 + sSpriteAnim_HoennSeenOwnDigit0, + sSpriteAnim_HoennSeenOwnDigit1, + sSpriteAnim_HoennSeenOwnDigit2, + sSpriteAnim_HoennSeenOwnDigit3, + sSpriteAnim_HoennSeenOwnDigit4, + sSpriteAnim_HoennSeenOwnDigit5, + sSpriteAnim_HoennSeenOwnDigit6, + sSpriteAnim_HoennSeenOwnDigit7, + sSpriteAnim_HoennSeenOwnDigit8, + sSpriteAnim_HoennSeenOwnDigit9 }; -static const union AnimCmd *const sSpriteAnimTable_855D168[] = +static const union AnimCmd *const sSpriteAnimTable_NationalSeenOwnNumber[] = { - sSpriteAnim_855D0BC, - sSpriteAnim_855D0C4, - sSpriteAnim_855D0CC, - sSpriteAnim_855D0D4, - sSpriteAnim_855D0DC, - sSpriteAnim_855D0E4, - sSpriteAnim_855D0EC, - sSpriteAnim_855D0F4, - sSpriteAnim_855D0FC, - sSpriteAnim_855D104 + sSpriteAnim_NationalSeenOwnDigit0, + sSpriteAnim_NationalSeenOwnDigit1, + sSpriteAnim_NationalSeenOwnDigit2, + sSpriteAnim_NationalSeenOwnDigit3, + sSpriteAnim_NationalSeenOwnDigit4, + sSpriteAnim_NationalSeenOwnDigit5, + sSpriteAnim_NationalSeenOwnDigit6, + sSpriteAnim_NationalSeenOwnDigit7, + sSpriteAnim_NationalSeenOwnDigit8, + sSpriteAnim_NationalSeenOwnDigit9 }; -static const union AnimCmd *const sSpriteAnimTable_855D190[] = +static const union AnimCmd *const sSpriteAnimTable_DexListStartMenuCursor[] = { - sSpriteAnim_855D10C + sSpriteAnim_DexListStartMenuCursor }; static const struct SpriteTemplate sScrollBarSpriteTemplate = { .tileTag = 4096, .paletteTag = 4096, - .oam = &sOamData_855CFE4, - .anims = sSpriteAnimTable_855D114, + .oam = &sOamData_ScrollBar, + .anims = sSpriteAnimTable_ScrollBar, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCB_Scrollbar, }; -static const struct SpriteTemplate sArrowSpriteTemplate = +static const struct SpriteTemplate sScrollArrowSpriteTemplate = { .tileTag = 4096, .paletteTag = 4096, - .oam = &sOamData_855CFEC, - .anims = sSpriteAnimTable_855D118, + .oam = &sOamData_ScrollArrow, + .anims = sSpriteAnimTable_ScrollArrow, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_80BE658, + .callback = SpriteCB_ScrollArrow, }; static const struct SpriteTemplate sInterfaceTextSpriteTemplate = { .tileTag = 4096, .paletteTag = 4096, - .oam = &sOamData_855CFF4, - .anims = sSpriteAnimTable_855D120, + .oam = &sOamData_InterfaceText, + .anims = sSpriteAnimTable_InterfaceText, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_80BE758, + .callback = SpriteCB_DexListInterfaceText, }; -static const struct SpriteTemplate sRotatingPokeballSpriteTemplate = +static const struct SpriteTemplate sRotatingPokeBallSpriteTemplate = { .tileTag = 4096, .paletteTag = 4096, - .oam = &sOamData_855CFFC, - .anims = sSpriteAnimTable_855D11C, + .oam = &sOamData_RotatingPokeBall, + .anims = sSpriteAnimTable_RotatingPokeBall, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_80BE780, + .callback = SpriteCB_RotatingPokeBall, }; static const struct SpriteTemplate sSeenOwnTextSpriteTemplate = { .tileTag = 4096, .paletteTag = 4096, - .oam = &sOamData_855D004, - .anims = sSpriteAnimTable_855D130, + .oam = &sOamData_SeenOwnText, + .anims = sSpriteAnimTable_SeenOwnText, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_80BE44C, + .callback = SpriteCB_SeenOwnInfo, }; -static const struct SpriteTemplate gUnknown_0855D20C = +static const struct SpriteTemplate sHoennNationalTextSpriteTemplate = { .tileTag = 4096, .paletteTag = 4096, - .oam = &sOamData_855CFF4, - .anims = sSpriteAnimTable_855D138, + .oam = &sOamData_InterfaceText, + .anims = sSpriteAnimTable_HoennNationalText, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_80BE44C, + .callback = SpriteCB_SeenOwnInfo, }; -static const struct SpriteTemplate gUnknown_0855D224 = +static const struct SpriteTemplate sHoennDexSeenOwnNumberSpriteTemplate = { .tileTag = 4096, .paletteTag = 4096, - .oam = &sOamData_855D00C, - .anims = sSpriteAnimTable_855D140, + .oam = &sOamData_Dex8x16, + .anims = sSpriteAnimTable_HoennSeenOwnNumber, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_80BE44C, + .callback = SpriteCB_SeenOwnInfo, }; -static const struct SpriteTemplate gUnknown_0855D23C = +static const struct SpriteTemplate sNationalDexSeenOwnNumberSpriteTemplate = { .tileTag = 4096, .paletteTag = 4096, - .oam = &sOamData_855D00C, - .anims = sSpriteAnimTable_855D168, + .oam = &sOamData_Dex8x16, + .anims = sSpriteAnimTable_NationalSeenOwnNumber, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_80BE44C, + .callback = SpriteCB_SeenOwnInfo, }; -static const struct SpriteTemplate gUnknown_0855D254 = +static const struct SpriteTemplate sDexListStartMenuCursorSpriteTemplate = { .tileTag = 4096, .paletteTag = 4096, - .oam = &sOamData_855D00C, - .anims = sSpriteAnimTable_855D190, + .oam = &sOamData_Dex8x16, + .anims = sSpriteAnimTable_DexListStartMenuCursor, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_80BE834, + .callback = SpriteCB_DexListStartMenuCursor, }; static const struct CompressedSpriteSheet sInterfaceSpriteSheet[] = { - {gPokedexMenu2_Gfx, 0x2000, 4096}, + {gPokedexInterface_Gfx, 0x2000, 4096}, {0} }; static const struct SpritePalette sInterfaceSpritePalette[] = { - {gPokedexText_Pal, 4096}, + {gPokedexBgHoenn_Pal, 4096}, {0} }; -static const u8 gUnknown_0855D28C[] = {0x4, 0x8, 0x10, 0x20, 0x20}; -static const u8 gUnknown_0855D291[] = {0x8, 0x4, 0x2, 0x1, 0x1}; +// By scroll speed. Last element of each unused +static const u8 sScrollMonIncrements[] = {4, 8, 16, 32, 32}; +static const u8 sScrollTimers[] = {8, 4, 2, 1, 1}; static const struct BgTemplate sPokedex_BgTemplate[] = { @@ -772,7 +836,7 @@ static const struct WindowTemplate sPokemonList_WindowTemplate[] = }; static const u8 sText_No000[] = _("{NO}000"); -static const u8 gUnknown_0855D2BE[] = INCBIN_U8("graphics/pokedex/caught_ball.4bpp"); +static const u8 sCaughtBall_Gfx[] = INCBIN_U8("graphics/pokedex/caught_ball.4bpp"); static const u8 sText_TenDashes[] = _("----------"); ALIGNED(4) static const u8 gExpandedPlaceholder_PokedexDescription[] = _(""); @@ -780,7 +844,7 @@ ALIGNED(4) static const u8 gExpandedPlaceholder_PokedexDescription[] = _(""); #include "data/pokemon/pokedex_text.h" #include "data/pokemon/pokedex_entries.h" -static const u16 gUnknown_0856E610[] = INCBIN_U16("graphics/pokedex/black.gbapal"); +static const u16 sSizeScreenSilhouette_Pal[] = INCBIN_U16("graphics/pokedex/size_silhouette.gbapal"); static const struct BgTemplate sInfoScreen_BgTemplate[] = { @@ -829,41 +893,45 @@ static const struct BgTemplate sInfoScreen_BgTemplate[] = static const struct WindowTemplate sInfoScreen_WindowTemplates[] = { - { // WIN_INFO + [WIN_INFO] = + { .bg = 2, .tilemapLeft = 0, .tilemapTop = 0, .width = 32, .height = 20, .paletteNum = 0, - .baseBlock = 0x0001, + .baseBlock = 1, }, - { // WIN_FOOTPRINT + [WIN_FOOTPRINT] = + { .bg = 2, .tilemapLeft = 25, .tilemapTop = 8, .width = 2, .height = 2, .paletteNum = 15, - .baseBlock = 0x0281, + .baseBlock = 641, }, - { // WIN_CRY_WAVE + [WIN_CRY_WAVE] = + { .bg = 0, .tilemapLeft = 0, .tilemapTop = 12, .width = 32, .height = 7, .paletteNum = 8, - .baseBlock = 0x0285, + .baseBlock = 645, }, - { // WIN_VU_METER + [WIN_VU_METER] = + { .bg = 2, .tilemapLeft = 18, .tilemapTop = 3, .width = 10, .height = 8, .paletteNum = 9, - .baseBlock = 0x0365, + .baseBlock = 869, }, DUMMY_WIN_TEMPLATE }; @@ -892,23 +960,25 @@ static const struct BgTemplate sNewEntryInfoScreen_BgTemplate[] = static const struct WindowTemplate sNewEntryInfoScreen_WindowTemplates[] = { - { // WIN_INFO + [WIN_INFO] = + { .bg = 2, .tilemapLeft = 0, .tilemapTop = 0, .width = 32, .height = 20, .paletteNum = 0, - .baseBlock = 0x0001, + .baseBlock = 1, }, - { // WIN_FOOTPRINT + [WIN_FOOTPRINT] = + { .bg = 2, .tilemapLeft = 25, .tilemapTop = 8, .width = 2, .height = 2, .paletteNum = 15, - .baseBlock = 0x0281, + .baseBlock = 641, }, DUMMY_WIN_TEMPLATE }; @@ -917,203 +987,392 @@ static const u8 sText_TenDashes2[] = _("----------"); #include "data/pokemon_graphics/footprint_table.h" -static const u8 gUnknown_0856ED08[][4] = +// First character in range followed by number of characters in range for upper and lowercase +static const u8 sLetterSearchRanges[][4] = { - {0x00, 0x00, 0x00, 0x00}, - {0xbb, 0x03, 0xd5, 0x03}, - {0xbe, 0x03, 0xd8, 0x03}, - {0xc1, 0x03, 0xdb, 0x03}, - {0xc4, 0x03, 0xde, 0x03}, - {0xc7, 0x03, 0xe1, 0x03}, - {0xca, 0x03, 0xe4, 0x03}, - {0xcd, 0x03, 0xe7, 0x03}, - {0xd0, 0x03, 0xea, 0x03}, - {0xd3, 0x02, 0xed, 0x02}, + {}, // Name not specified, shouldn't be reached + [NAME_ABC] = {CHAR_A, 3, CHAR_a, 3}, + [NAME_DEF] = {CHAR_D, 3, CHAR_d, 3}, + [NAME_GHI] = {CHAR_G, 3, CHAR_g, 3}, + [NAME_JKL] = {CHAR_J, 3, CHAR_j, 3}, + [NAME_MNO] = {CHAR_M, 3, CHAR_m, 3}, + [NAME_PQR] = {CHAR_P, 3, CHAR_p, 3}, + [NAME_STU] = {CHAR_S, 3, CHAR_s, 3}, + [NAME_VWX] = {CHAR_V, 3, CHAR_v, 3}, + [NAME_YZ] = {CHAR_Y, 2, CHAR_y, 2}, }; -static const struct UnknownStruct3 gUnknown_0856ED30[] = +#define LETTER_IN_RANGE_UPPER(letter, range) \ + ((letter) >= sLetterSearchRanges[range][0] \ + && (letter) < sLetterSearchRanges[range][0] + sLetterSearchRanges[range][1]) \ + +#define LETTER_IN_RANGE_LOWER(letter, range) \ + ((letter) >= sLetterSearchRanges[range][2] \ + && (letter) < sLetterSearchRanges[range][2] + sLetterSearchRanges[range][3]) \ + +static const struct SearchMenuTopBarItem sSearchMenuTopBarItems[SEARCH_TOPBAR_COUNT] = { + [SEARCH_TOPBAR_SEARCH] = { - .text = gText_SearchForPkmnBasedOnParameters, - .unk4 = 0, - .unk5 = 0, - .unk6 = 5, + .description = gText_SearchForPkmnBasedOnParameters, + .highlightX = 0, + .highlightY = 0, + .highlightWidth = 5, }, + [SEARCH_TOPBAR_SHIFT] = { - .text = gText_SwitchPokedexListings, - .unk4 = 6, - .unk5 = 0, - .unk6 = 5, + .description = gText_SwitchPokedexListings, + .highlightX = 6, + .highlightY = 0, + .highlightWidth = 5, }, + [SEARCH_TOPBAR_CANCEL] = { - .text = gText_ReturnToPokedex, - .unk4 = 12, - .unk5 = 0, - .unk6 = 5, + .description = gText_ReturnToPokedex, + .highlightX = 12, + .highlightY = 0, + .highlightWidth = 5, }, }; -static const struct UnknownStruct4 gUnknown_0856ED48[] = +static const struct SearchMenuItem sSearchMenuItems[SEARCH_COUNT] = { + [SEARCH_NAME] = { - .text = gText_ListByFirstLetter, - .unk4 = 0, - .unk5 = 2, - .unk6 = 5, - .unk7 = 5, - .unk8 = 2, - .unk9 = 12, + .description = gText_ListByFirstLetter, + .titleBgX = 0, + .titleBgY = 2, + .titleBgWidth = 5, + .selectionBgX = 5, + .selectionBgY = 2, + .selectionBgWidth = 12, }, + [SEARCH_COLOR] = { - .text = gText_ListByBodyColor, - .unk4 = 0, - .unk5 = 4, - .unk6 = 5, - .unk7 = 5, - .unk8 = 4, - .unk9 = 12, + .description = gText_ListByBodyColor, + .titleBgX = 0, + .titleBgY = 4, + .titleBgWidth = 5, + .selectionBgX = 5, + .selectionBgY = 4, + .selectionBgWidth = 12, }, + [SEARCH_TYPE_LEFT] = { - .text = gText_ListByType, - .unk4 = 0, - .unk5 = 6, - .unk6 = 5, - .unk7 = 5, - .unk8 = 6, - .unk9 = 6, + .description = gText_ListByType, + .titleBgX = 0, + .titleBgY = 6, + .titleBgWidth = 5, + .selectionBgX = 5, + .selectionBgY = 6, + .selectionBgWidth = 6, }, + [SEARCH_TYPE_RIGHT] = { - .text = gText_ListByType, - .unk4 = 0, - .unk5 = 6, - .unk6 = 5, - .unk7 = 11, - .unk8 = 6, - .unk9 = 6, + .description = gText_ListByType, + .titleBgX = 0, + .titleBgY = 6, + .titleBgWidth = 5, + .selectionBgX = 11, + .selectionBgY = 6, + .selectionBgWidth = 6, }, + [SEARCH_ORDER] = { - .text = gText_SelectPokedexListingMode, - .unk4 = 0, - .unk5 = 8, - .unk6 = 5, - .unk7 = 5, - .unk8 = 8, - .unk9 = 12, + .description = gText_SelectPokedexListingMode, + .titleBgX = 0, + .titleBgY = 8, + .titleBgWidth = 5, + .selectionBgX = 5, + .selectionBgY = 8, + .selectionBgWidth = 12, }, + [SEARCH_MODE] = { - .text = gText_SelectPokedexMode, - .unk4 = 0, - .unk5 = 10, - .unk6 = 5, - .unk7 = 5, - .unk8 = 10, - .unk9 = 12, + .description = gText_SelectPokedexMode, + .titleBgX = 0, + .titleBgY = 10, + .titleBgWidth = 5, + .selectionBgX = 5, + .selectionBgY = 10, + .selectionBgWidth = 12, }, + [SEARCH_OK] = { - .text = gText_ExecuteSearchSwitch, - .unk4 = 0, - .unk5 = 12, - .unk6 = 5, - .unk7 = 0, - .unk8 = 0, - .unk9 = 0, + .description = gText_ExecuteSearchSwitch, + .titleBgX = 0, + .titleBgY = 12, + .titleBgWidth = 5, + .selectionBgX = 0, + .selectionBgY = 0, + .selectionBgWidth = 0, }, }; -static const u8 gUnknown_0856ED9C[][4] = +// Left, Right, Up, Down +static const u8 sSearchMovementMap_SearchNatDex[SEARCH_COUNT][4] = { - {0xFF, 0xFF, 0xFF, 1}, - {0xFF, 0xFF, 0, 2}, - {0xFF, 3, 1, 4}, - { 2, 0xFF, 1, 4}, - {0xFF, 0xFF, 2, 5}, - {0xFF, 0xFF, 4, 6}, - {0xFF, 0xFF, 5, 0xFF}, + [SEARCH_NAME] = + { + 0xFF, + 0xFF, + 0xFF, + SEARCH_COLOR + }, + [SEARCH_COLOR] = + { + 0xFF, + 0xFF, + SEARCH_NAME, + SEARCH_TYPE_LEFT + }, + [SEARCH_TYPE_LEFT] = + { + 0xFF, + SEARCH_TYPE_RIGHT, + SEARCH_COLOR, + SEARCH_ORDER + }, + [SEARCH_TYPE_RIGHT] = + { SEARCH_TYPE_LEFT, + 0xFF, + SEARCH_COLOR, + SEARCH_ORDER + }, + [SEARCH_ORDER] = + { + 0xFF, + 0xFF, + SEARCH_TYPE_LEFT, + SEARCH_MODE + }, + [SEARCH_MODE] = + { + 0xFF, + 0xFF, + SEARCH_ORDER, + SEARCH_OK + }, + [SEARCH_OK] = + { + 0xFF, + 0xFF, + SEARCH_MODE, + 0xFF + }, }; -static const u8 gUnknown_0856EDB8[][4] = +// Left, Right, Up, Down +static const u8 sSearchMovementMap_ShiftNatDex[SEARCH_COUNT][4] = { - {0xFF, 0xFF, 0xFF, 0xFF}, - {0xFF, 0xFF, 0xFF, 0xFF}, - {0xFF, 0xFF, 0xFF, 0xFF}, - {0xFF, 0xFF, 0xFF, 0xFF}, - {0xFF, 0xFF, 0xFF, 5}, - {0xFF, 0xFF, 4, 6}, - {0xFF, 0xFF, 5, 0xFF}, + [SEARCH_NAME] = + { + 0xFF, + 0xFF, + 0xFF, + 0xFF + }, + [SEARCH_COLOR] = + { + 0xFF, + 0xFF, + 0xFF, + 0xFF + }, + [SEARCH_TYPE_LEFT] = + { + 0xFF, + 0xFF, + 0xFF, + 0xFF + }, + [SEARCH_TYPE_RIGHT] = + { + 0xFF, + 0xFF, + 0xFF, + 0xFF + }, + [SEARCH_ORDER] = + { + 0xFF, + 0xFF, + 0xFF, + SEARCH_MODE + }, + [SEARCH_MODE] = + { + 0xFF, + 0xFF, + SEARCH_ORDER, + SEARCH_OK + }, + [SEARCH_OK] = + { + 0xFF, + 0xFF, + SEARCH_MODE, + 0xFF + }, }; -static const u8 gUnknown_0856EDD4[][4] = +// Left, Right, Up, Down +static const u8 sSearchMovementMap_SearchHoennDex[SEARCH_COUNT][4] = { - {0xFF, 0xFF, 0xFF, 1}, - {0xFF, 0xFF, 0, 2}, - {0xFF, 3, 1, 4}, - { 2, 0xFF, 1, 4}, - {0xFF, 0xFF, 2, 6}, - {0xFF, 0xFF, 0xFF, 0xFF}, - {0xFF, 0xFF, 4, 0xFF}, + [SEARCH_NAME] = + { + 0xFF, + 0xFF, + 0xFF, + SEARCH_COLOR + }, + [SEARCH_COLOR] = + { + 0xFF, + 0xFF, + SEARCH_NAME, + SEARCH_TYPE_LEFT + }, + [SEARCH_TYPE_LEFT] = + { + 0xFF, + SEARCH_TYPE_RIGHT, + SEARCH_COLOR, + SEARCH_ORDER + }, + [SEARCH_TYPE_RIGHT] = + { SEARCH_TYPE_LEFT, + 0xFF, + SEARCH_COLOR, + SEARCH_ORDER + }, + [SEARCH_ORDER] = + { + 0xFF, + 0xFF, + SEARCH_TYPE_LEFT, + SEARCH_OK + }, + [SEARCH_MODE] = + { + 0xFF, + 0xFF, + 0xFF, + 0xFF + }, + [SEARCH_OK] = + { + 0xFF, + 0xFF, + SEARCH_ORDER, + 0xFF + }, }; -static const u8 gUnknown_0856EDF0[][4] = +// Left, Right, Up, Down +static const u8 sSearchMovementMap_ShiftHoennDex[SEARCH_COUNT][4] = { - {0xFF, 0xFF, 0xFF, 0xFF}, - {0xFF, 0xFF, 0xFF, 0xFF}, - {0xFF, 0xFF, 0xFF, 0xFF}, - {0xFF, 0xFF, 0xFF, 0xFF}, - {0xFF, 0xFF, 0xFF, 6}, - {0xFF, 0xFF, 0xFF, 0xFF}, - {0xFF, 0xFF, 4, 0xFF}, + [SEARCH_NAME] = + { + 0xFF, + 0xFF, + 0xFF, + 0xFF + }, + [SEARCH_COLOR] = + { + 0xFF, + 0xFF, + 0xFF, + 0xFF + }, + [SEARCH_TYPE_LEFT] = + { + 0xFF, + 0xFF, + 0xFF, + 0xFF + }, + [SEARCH_TYPE_RIGHT] = + { + 0xFF, + 0xFF, + 0xFF, + 0xFF + }, + [SEARCH_ORDER] = + { + 0xFF, + 0xFF, + 0xFF, + SEARCH_OK + }, + [SEARCH_MODE] = + { + 0xFF, + 0xFF, + 0xFF, + 0xFF + }, + [SEARCH_OK] = + { + 0xFF, + 0xFF, + SEARCH_ORDER, + 0xFF + }, }; -static const struct PokedexOption gDexModeOptions[] = +static const struct SearchOptionText sDexModeOptions[] = { - {gText_DexHoennDescription, gText_DexHoennTitle}, - {gText_DexNatDescription, gText_DexNatTitle}, - {NULL, NULL}, + [DEX_MODE_HOENN] = {gText_DexHoennDescription, gText_DexHoennTitle}, + [DEX_MODE_NATIONAL] = {gText_DexNatDescription, gText_DexNatTitle}, + {}, }; -static const struct PokedexOption gDexSortOptions[] = +static const struct SearchOptionText sDexOrderOptions[] = { - {gText_DexSortNumericalDescription, gText_DexSortNumericalTitle}, - {gText_DexSortAtoZDescription, gText_DexSortAtoZTitle}, - {gText_DexSortHeaviestDescription, gText_DexSortHeaviestTitle}, - {gText_DexSortLightestDescription, gText_DexSortLightestTitle}, - {gText_DexSortTallestDescription, gText_DexSortTallestTitle}, - {gText_DexSortSmallestDescription, gText_DexSortSmallestTitle}, - {NULL, NULL}, + [ORDER_NUMERICAL] = {gText_DexSortNumericalDescription, gText_DexSortNumericalTitle}, + [ORDER_ALPHABETICAL] = {gText_DexSortAtoZDescription, gText_DexSortAtoZTitle}, + [ORDER_HEAVIEST] = {gText_DexSortHeaviestDescription, gText_DexSortHeaviestTitle}, + [ORDER_LIGHTEST] = {gText_DexSortLightestDescription, gText_DexSortLightestTitle}, + [ORDER_TALLEST] = {gText_DexSortTallestDescription, gText_DexSortTallestTitle}, + [ORDER_SMALLEST] = {gText_DexSortSmallestDescription, gText_DexSortSmallestTitle}, + {}, }; -static const struct PokedexOption gDexSearchAlphaOptions[] = +static const struct SearchOptionText sDexSearchNameOptions[] = { {gText_DexEmptyString, gText_DexSearchDontSpecify}, - {gText_DexEmptyString, gText_DexSearchAlphaABC}, - {gText_DexEmptyString, gText_DexSearchAlphaDEF}, - {gText_DexEmptyString, gText_DexSearchAlphaGHI}, - {gText_DexEmptyString, gText_DexSearchAlphaJKL}, - {gText_DexEmptyString, gText_DexSearchAlphaMNO}, - {gText_DexEmptyString, gText_DexSearchAlphaPQR}, - {gText_DexEmptyString, gText_DexSearchAlphaSTU}, - {gText_DexEmptyString, gText_DexSearchAlphaVWX}, - {gText_DexEmptyString, gText_DexSearchAlphaYZ}, - {NULL, NULL}, + [NAME_ABC] = {gText_DexEmptyString, gText_DexSearchAlphaABC}, + [NAME_DEF] = {gText_DexEmptyString, gText_DexSearchAlphaDEF}, + [NAME_GHI] = {gText_DexEmptyString, gText_DexSearchAlphaGHI}, + [NAME_JKL] = {gText_DexEmptyString, gText_DexSearchAlphaJKL}, + [NAME_MNO] = {gText_DexEmptyString, gText_DexSearchAlphaMNO}, + [NAME_PQR] = {gText_DexEmptyString, gText_DexSearchAlphaPQR}, + [NAME_STU] = {gText_DexEmptyString, gText_DexSearchAlphaSTU}, + [NAME_VWX] = {gText_DexEmptyString, gText_DexSearchAlphaVWX}, + [NAME_YZ] = {gText_DexEmptyString, gText_DexSearchAlphaYZ}, + {}, }; -static const struct PokedexOption gDexSearchColorOptions[] = +static const struct SearchOptionText sDexSearchColorOptions[] = { {gText_DexEmptyString, gText_DexSearchDontSpecify}, - {gText_DexEmptyString, gText_DexSearchColorRed}, - {gText_DexEmptyString, gText_DexSearchColorBlue}, - {gText_DexEmptyString, gText_DexSearchColorYellow}, - {gText_DexEmptyString, gText_DexSearchColorGreen}, - {gText_DexEmptyString, gText_DexSearchColorBlack}, - {gText_DexEmptyString, gText_DexSearchColorBrown}, - {gText_DexEmptyString, gText_DexSearchColorPurple}, - {gText_DexEmptyString, gText_DexSearchColorGray}, - {gText_DexEmptyString, gText_DexSearchColorWhite}, - {gText_DexEmptyString, gText_DexSearchColorPink}, - {NULL, NULL}, + [BODY_COLOR_RED + 1] = {gText_DexEmptyString, gText_DexSearchColorRed}, + [BODY_COLOR_BLUE + 1] = {gText_DexEmptyString, gText_DexSearchColorBlue}, + [BODY_COLOR_YELLOW + 1] = {gText_DexEmptyString, gText_DexSearchColorYellow}, + [BODY_COLOR_GREEN + 1] = {gText_DexEmptyString, gText_DexSearchColorGreen}, + [BODY_COLOR_BLACK + 1] = {gText_DexEmptyString, gText_DexSearchColorBlack}, + [BODY_COLOR_BROWN + 1] = {gText_DexEmptyString, gText_DexSearchColorBrown}, + [BODY_COLOR_PURPLE + 1] = {gText_DexEmptyString, gText_DexSearchColorPurple}, + [BODY_COLOR_GRAY + 1] = {gText_DexEmptyString, gText_DexSearchColorGray}, + [BODY_COLOR_WHITE + 1] = {gText_DexEmptyString, gText_DexSearchColorWhite}, + [BODY_COLOR_PINK + 1] = {gText_DexEmptyString, gText_DexSearchColorPink}, + {}, }; -static const struct PokedexOption gDexSearchTypeOptions[] = +static const struct SearchOptionText sDexSearchTypeOptions[] = { {gText_DexEmptyString, gText_DexSearchTypeNone}, {gText_DexEmptyString, gTypeNames[TYPE_NORMAL]}, @@ -1133,36 +1392,21 @@ static const struct PokedexOption gDexSearchTypeOptions[] = {gText_DexEmptyString, gTypeNames[TYPE_ICE]}, {gText_DexEmptyString, gTypeNames[TYPE_DRAGON]}, {gText_DexEmptyString, gTypeNames[TYPE_DARK]}, - {NULL, NULL}, + {}, }; - -#define SEARCH_NAME 0 -#define SEARCH_COLOR 1 -#define SEARCH_TYPE_1 2 -#define SEARCH_TYPE_2 3 -#define SEARCH_ORDER 4 -#define SEARCH_DEX_MODE 5 - -#define SORT_NUMERICAL 0 -#define SORT_ALPHABETICAL 1 -#define SORT_HEAVIEST 2 -#define SORT_LIGHTEST 3 -#define SORT_TALLEST 4 -#define SORT_SMALLEST 5 - static const u8 sPokedexModes[] = {DEX_MODE_HOENN, DEX_MODE_NATIONAL}; -static const u8 sSortOptions[] = +static const u8 sOrderOptions[] = { - SORT_NUMERICAL, - SORT_ALPHABETICAL, - SORT_HEAVIEST, - SORT_LIGHTEST, - SORT_TALLEST, - SORT_SMALLEST, + ORDER_NUMERICAL, + ORDER_ALPHABETICAL, + ORDER_HEAVIEST, + ORDER_LIGHTEST, + ORDER_TALLEST, + ORDER_SMALLEST, }; -static const u8 gDexSearchTypeIds[] = +static const u8 sDexSearchTypeIds[] = { TYPE_NONE, TYPE_NORMAL, @@ -1184,14 +1428,16 @@ static const u8 gDexSearchTypeIds[] = TYPE_DARK, }; -static const struct UnknownStruct1 sSearchOptions[] = +// Number pairs are the task data for tracking the cursor pos and scroll offset of each option list +// See task data defines above Task_LoadSearchMenu +static const struct SearchOption sSearchOptions[] = { - {gDexSearchAlphaOptions, 6, 7, 10}, - {gDexSearchColorOptions, 8, 9, 11}, - {gDexSearchTypeOptions, 10, 11, NUMBER_OF_MON_TYPES}, - {gDexSearchTypeOptions, 12, 13, NUMBER_OF_MON_TYPES}, - {gDexSortOptions, 4, 5, 6}, - {gDexModeOptions, 2, 3, 2}, + [SEARCH_NAME] = {sDexSearchNameOptions, 6, 7, ARRAY_COUNT(sDexSearchNameOptions) - 1}, + [SEARCH_COLOR] = {sDexSearchColorOptions, 8, 9, ARRAY_COUNT(sDexSearchColorOptions) - 1}, + [SEARCH_TYPE_LEFT] = {sDexSearchTypeOptions, 10, 11, ARRAY_COUNT(sDexSearchTypeOptions) - 1}, + [SEARCH_TYPE_RIGHT] = {sDexSearchTypeOptions, 12, 13, ARRAY_COUNT(sDexSearchTypeOptions) - 1}, + [SEARCH_ORDER] = {sDexOrderOptions, 4, 5, ARRAY_COUNT(sDexOrderOptions) - 1}, + [SEARCH_MODE] = {sDexModeOptions, 2, 3, ARRAY_COUNT(sDexModeOptions) - 1}, }; static const struct BgTemplate sSearchMenu_BgTemplate[] = @@ -1254,8 +1500,8 @@ void ResetPokedex(void) { u16 i; - gUnknown_02039B50 = 0; - gUnknown_02039B52 = 64; + sLastSelectedPokemon = 0; + sPokeBallRotation = POKEBALL_ROTATION_TOP; gUnusedPokedexU8 = 0; gSaveBlock2Ptr->pokedex.mode = DEX_MODE_HOENN; gSaveBlock2Ptr->pokedex.order = 0; @@ -1276,11 +1522,11 @@ void ResetPokedex(void) void ResetPokedexScrollPositions(void) { - gUnknown_02039B50 = 0; - gUnknown_02039B52 = 64; + sLastSelectedPokemon = 0; + sPokeBallRotation = POKEBALL_ROTATION_TOP; } -void sub_80BB370(void) +static void VBlankCB_Pokedex(void) { LoadOam(); ProcessSpriteCopyRequests(); @@ -1294,111 +1540,111 @@ static void ResetPokedexView(struct PokedexView *pokedexView) for (i = 0; i < NATIONAL_DEX_COUNT; i++) { pokedexView->pokedexList[i].dexNum = 0xFFFF; - pokedexView->pokedexList[i].seen = 0; - pokedexView->pokedexList[i].owned = 0; + pokedexView->pokedexList[i].seen = FALSE; + pokedexView->pokedexList[i].owned = FALSE; } - pokedexView->unk608 = 0; - pokedexView->unk60A_1 = 0; - pokedexView->unk60A_2 = 0; + pokedexView->pokedexList[NATIONAL_DEX_COUNT].dexNum = 0; + pokedexView->pokedexList[NATIONAL_DEX_COUNT].seen = FALSE; + pokedexView->pokedexList[NATIONAL_DEX_COUNT].owned = FALSE; pokedexView->pokemonListCount = 0; pokedexView->selectedPokemon = 0; - pokedexView->unk610 = 0; - pokedexView->dexMode = 0; - pokedexView->unk614 = 0; - pokedexView->dexOrder = 0; - pokedexView->unk618 = 0; + pokedexView->selectedPokemonBackup = 0; + pokedexView->dexMode = DEX_MODE_HOENN; + pokedexView->dexModeBackup = DEX_MODE_HOENN; + pokedexView->dexOrder = ORDER_NUMERICAL; + pokedexView->dexOrderBackup = ORDER_NUMERICAL; pokedexView->seenCount = 0; pokedexView->ownCount = 0; - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_MONS_ON_SCREEN; i++) pokedexView->monSpriteIds[i] = 0xFFFF; - pokedexView->unk628 = 0; - pokedexView->unk62A = 0; - pokedexView->unk62C = 0; + pokedexView->pokeBallRotationStep = 0; + pokedexView->pokeBallRotationBackup = 0; + pokedexView->pokeBallRotation = 0; pokedexView->initialVOffset = 0; - pokedexView->unk62E = 0; - pokedexView->unk62F = 0; - pokedexView->unk630 = 0; - pokedexView->unk632 = 0; - pokedexView->unk634 = 0; - pokedexView->unk636 = 0; - pokedexView->unk638 = 0; - for (i = 0; i <= 3; i++) - pokedexView->unk63A[i] = 0; - pokedexView->unk64A = 0; - pokedexView->unk64B = 0; - pokedexView->unk64C_1 = 0; - pokedexView->selectedScreen = 0; - pokedexView->unk64E = 0; + pokedexView->scrollTimer = 0; + pokedexView->scrollDirection = 0; + pokedexView->listVOffset = 0; + pokedexView->listMovingVOffset = 0; + pokedexView->scrollMonIncrement = 0; + pokedexView->maxScrollTimer = 0; + pokedexView->scrollSpeed = 0; + for (i = 0; i < ARRAY_COUNT(pokedexView->unkArr1); i++) + pokedexView->unkArr1[i] = 0; + pokedexView->currentPage = PAGE_MAIN; + pokedexView->currentPageBackup = PAGE_MAIN; + pokedexView->isSearchResults = FALSE; + pokedexView->selectedScreen = AREA_SCREEN; + pokedexView->screenSwitchState = 0; pokedexView->menuIsOpen = 0; pokedexView->menuCursorPos = 0; pokedexView->menuY = 0; - for (i = 0; i <= 7; i++) - pokedexView->unk654[i] = 0; - for (i = 0; i <= 7; i++) - pokedexView->unk65C[i] = 0; + for (i = 0; i < ARRAY_COUNT(pokedexView->unkArr2); i++) + pokedexView->unkArr2[i] = 0; + for (i = 0; i < ARRAY_COUNT(pokedexView->unkArr3); i++) + pokedexView->unkArr3[i] = 0; } -void CB2_Pokedex(void) +void CB2_OpenPokedex(void) { u8 *addr; u32 size; switch (gMain.state) { - case 0: - default: - SetVBlankCallback(NULL); - ResetOtherVideoRegisters(0); - DmaFillLarge16(3, 0, (u8 *)VRAM, VRAM_SIZE, 0x1000); - DmaClear32(3, OAM, OAM_SIZE); - DmaClear16(3, PLTT, PLTT_SIZE); - gMain.state = 1; - break; - case 1: - ScanlineEffect_Stop(); - ResetTasks(); - ResetSpriteData(); - ResetPaletteFade(); - FreeAllSpritePalettes(); - gReservedSpritePaletteCount = 8; - ResetAllPicSprites(); - gMain.state++; - break; - case 2: - sPokedexView = AllocZeroed(sizeof(struct PokedexView)); - ResetPokedexView(sPokedexView); - CreateTask(sub_80BB78C, 0); - sPokedexView->dexMode = gSaveBlock2Ptr->pokedex.mode; - if (!IsNationalPokedexEnabled()) - sPokedexView->dexMode = DEX_MODE_HOENN; - sPokedexView->dexOrder = gSaveBlock2Ptr->pokedex.order; - sPokedexView->selectedPokemon = gUnknown_02039B50; - sPokedexView->unk62C = gUnknown_02039B52; - sPokedexView->selectedScreen = 0; - if (!IsNationalPokedexEnabled()) - { - sPokedexView->seenCount = GetHoennPokedexCount(FLAG_GET_SEEN); - sPokedexView->ownCount = GetHoennPokedexCount(FLAG_GET_CAUGHT); - } - else - { - sPokedexView->seenCount = GetNationalPokedexCount(FLAG_GET_SEEN); - sPokedexView->ownCount = GetNationalPokedexCount(FLAG_GET_CAUGHT); - } - sPokedexView->initialVOffset = 8; - gMain.state++; - break; - case 3: - EnableInterrupts(1); - SetVBlankCallback(sub_80BB370); - SetMainCallback2(sub_80BB774); - CreatePokedexList(sPokedexView->dexMode, sPokedexView->dexOrder); - m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x80); - break; + case 0: + default: + SetVBlankCallback(NULL); + ResetOtherVideoRegisters(0); + DmaFillLarge16(3, 0, (u8 *)VRAM, VRAM_SIZE, 0x1000); + DmaClear32(3, OAM, OAM_SIZE); + DmaClear16(3, PLTT, PLTT_SIZE); + gMain.state = 1; + break; + case 1: + ScanlineEffect_Stop(); + ResetTasks(); + ResetSpriteData(); + ResetPaletteFade(); + FreeAllSpritePalettes(); + gReservedSpritePaletteCount = 8; + ResetAllPicSprites(); + gMain.state++; + break; + case 2: + sPokedexView = AllocZeroed(sizeof(struct PokedexView)); + ResetPokedexView(sPokedexView); + CreateTask(Task_OpenPokedexMainPage, 0); + sPokedexView->dexMode = gSaveBlock2Ptr->pokedex.mode; + if (!IsNationalPokedexEnabled()) + sPokedexView->dexMode = DEX_MODE_HOENN; + sPokedexView->dexOrder = gSaveBlock2Ptr->pokedex.order; + sPokedexView->selectedPokemon = sLastSelectedPokemon; + sPokedexView->pokeBallRotation = sPokeBallRotation; + sPokedexView->selectedScreen = AREA_SCREEN; + if (!IsNationalPokedexEnabled()) + { + sPokedexView->seenCount = GetHoennPokedexCount(FLAG_GET_SEEN); + sPokedexView->ownCount = GetHoennPokedexCount(FLAG_GET_CAUGHT); + } + else + { + sPokedexView->seenCount = GetNationalPokedexCount(FLAG_GET_SEEN); + sPokedexView->ownCount = GetNationalPokedexCount(FLAG_GET_CAUGHT); + } + sPokedexView->initialVOffset = 8; + gMain.state++; + break; + case 3: + EnableInterrupts(1); + SetVBlankCallback(VBlankCB_Pokedex); + SetMainCallback2(CB2_Pokedex); + CreatePokedexList(sPokedexView->dexMode, sPokedexView->dexOrder); + m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x80); + break; } } -void sub_80BB774(void) +static void CB2_Pokedex(void) { RunTasks(); AnimateSprites(); @@ -1406,14 +1652,16 @@ void sub_80BB774(void) UpdatePaletteFade(); } -void sub_80BB78C(u8 taskId) +void Task_OpenPokedexMainPage(u8 taskId) { - sPokedexView->unk64C_1 = FALSE; - if (sub_80BC514(0)) - gTasks[taskId].func = sub_80BB7D4; + sPokedexView->isSearchResults = FALSE; + if (LoadPokedexListPage(PAGE_MAIN)) + gTasks[taskId].func = Task_HandlePokedexInput; } -void sub_80BB7D4(u8 taskId) +#define tTaskId data[0] + +static void Task_HandlePokedexInput(u8 taskId) { SetGpuReg(REG_OFFSET_BG0VOFS, sPokedexView->menuY); @@ -1427,57 +1675,56 @@ void sub_80BB7D4(u8 taskId) { UpdateSelectedMonSpriteId(); BeginNormalPaletteFade(~(1 << (gSprites[sPokedexView->selectedMonSpriteId].oam.paletteNum + 16)), 0, 0, 0x10, RGB_BLACK); - gSprites[sPokedexView->selectedMonSpriteId].callback = MoveMonIntoPosition; - gTasks[taskId].func = LoadPageOnceMonFinishedMoving; + gSprites[sPokedexView->selectedMonSpriteId].callback = SpriteCB_MoveMonForInfoScreen; + gTasks[taskId].func = Task_OpenInfoScreenAfterMonMovement; PlaySE(SE_PIN); FreeWindowAndBgBuffers(); } else if (gMain.newKeys & START_BUTTON) { - //Open menu sPokedexView->menuY = 0; - sPokedexView->menuIsOpen = 1; + sPokedexView->menuIsOpen = TRUE; sPokedexView->menuCursorPos = 0; - gTasks[taskId].func = sub_80BBA78; + gTasks[taskId].func = Task_HandlePokedexStartMenuInput; PlaySE(SE_SELECT); } else if (gMain.newKeys & SELECT_BUTTON) { PlaySE(SE_SELECT); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); - gTasks[taskId].data[0] = LoadSearchMenu(); - sPokedexView->unk64E = 0; - sPokedexView->unk62A = sPokedexView->unk62C; - sPokedexView->unk610 = sPokedexView->selectedPokemon; - sPokedexView->unk614 = sPokedexView->dexMode; - sPokedexView->unk618 = sPokedexView->dexOrder; - gTasks[taskId].func = sub_80BBD1C; + gTasks[taskId].tTaskId = LoadSearchMenu(); + sPokedexView->screenSwitchState = 0; + sPokedexView->pokeBallRotationBackup = sPokedexView->pokeBallRotation; + sPokedexView->selectedPokemonBackup = sPokedexView->selectedPokemon; + sPokedexView->dexModeBackup = sPokedexView->dexMode; + sPokedexView->dexOrderBackup = sPokedexView->dexOrder; + gTasks[taskId].func = Task_WaitForExitSearch; PlaySE(SE_PC_LOGIN); FreeWindowAndBgBuffers(); } else if (gMain.newKeys & B_BUTTON) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); - gTasks[taskId].func = sub_80BBDE8; + gTasks[taskId].func = Task_ClosePokedex; PlaySE(SE_PC_OFF); } else { //Handle D-pad - sPokedexView->selectedPokemon = sub_80BD69C(sPokedexView->selectedPokemon, 0xE); - if (sPokedexView->unk62E) - gTasks[taskId].func = sub_80BBA28; + sPokedexView->selectedPokemon = TryDoPokedexScroll(sPokedexView->selectedPokemon, 0xE); + if (sPokedexView->scrollTimer) + gTasks[taskId].func = Task_WaitForScroll; } } } -void sub_80BBA28(u8 taskId) +static void Task_WaitForScroll(u8 taskId) { - if (sub_80BD404(sPokedexView->unk62F, sPokedexView->unk634, sPokedexView->unk636)) - gTasks[taskId].func = sub_80BB7D4; + if (UpdateDexListScroll(sPokedexView->scrollDirection, sPokedexView->scrollMonIncrement, sPokedexView->maxScrollTimer)) + gTasks[taskId].func = Task_HandlePokedexInput; } -void sub_80BBA78(u8 taskId) +static void Task_HandlePokedexStartMenuInput(u8 taskId) { SetGpuReg(REG_OFFSET_BG0VOFS, sPokedexView->menuY); @@ -1492,37 +1739,37 @@ void sub_80BBA78(u8 taskId) { switch (sPokedexView->menuCursorPos) { - case 0: //BACK TO LIST - default: - gMain.newKeys |= START_BUTTON; //Exit menu - break; - case 1: //LIST TOP - sPokedexView->selectedPokemon = 0; - sPokedexView->unk62C = 0x40; - ClearMonSprites(); - CreateInitialPokemonSprites(sPokedexView->selectedPokemon, 0xE); - gMain.newKeys |= START_BUTTON; //Exit menu - break; - case 2: //LIST BOTTOM - sPokedexView->selectedPokemon = sPokedexView->pokemonListCount - 1; - sPokedexView->unk62C = sPokedexView->pokemonListCount * 16 + 0x30; - ClearMonSprites(); - CreateInitialPokemonSprites(sPokedexView->selectedPokemon, 0xE); - gMain.newKeys |= START_BUTTON; //Exit menu - break; - case 3: //CLOSE POKEDEX - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); - gTasks[taskId].func = sub_80BBDE8; - PlaySE(SE_PC_OFF); - break; + case 0: //BACK TO LIST + default: + gMain.newKeys |= START_BUTTON; //Exit menu + break; + case 1: //LIST TOP + sPokedexView->selectedPokemon = 0; + sPokedexView->pokeBallRotation = POKEBALL_ROTATION_TOP; + ClearMonSprites(); + CreateMonSpritesAtPos(sPokedexView->selectedPokemon, 0xE); + gMain.newKeys |= START_BUTTON; //Exit menu + break; + case 2: //LIST BOTTOM + sPokedexView->selectedPokemon = sPokedexView->pokemonListCount - 1; + sPokedexView->pokeBallRotation = sPokedexView->pokemonListCount * 16 + POKEBALL_ROTATION_BOTTOM; + ClearMonSprites(); + CreateMonSpritesAtPos(sPokedexView->selectedPokemon, 0xE); + gMain.newKeys |= START_BUTTON; //Exit menu + break; + case 3: //CLOSE POKEDEX + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); + gTasks[taskId].func = Task_ClosePokedex; + PlaySE(SE_PC_OFF); + break; } } //Exit menu when Start or B is pressed if (gMain.newKeys & (START_BUTTON | B_BUTTON)) { - sPokedexView->menuIsOpen = 0; - gTasks[taskId].func = sub_80BB7D4; + sPokedexView->menuIsOpen = FALSE; + gTasks[taskId].func = Task_HandlePokedexInput; PlaySE(SE_SELECT); } else if ((gMain.newAndRepeatedKeys & DPAD_UP) && sPokedexView->menuCursorPos != 0) @@ -1530,7 +1777,7 @@ void sub_80BBA78(u8 taskId) sPokedexView->menuCursorPos--; PlaySE(SE_SELECT); } - else if ((gMain.newAndRepeatedKeys & DPAD_DOWN) && sPokedexView->menuCursorPos <= 2) + else if ((gMain.newAndRepeatedKeys & DPAD_DOWN) && sPokedexView->menuCursorPos < 3) { sPokedexView->menuCursorPos++; PlaySE(SE_SELECT); @@ -1538,56 +1785,59 @@ void sub_80BBA78(u8 taskId) } } -void LoadPageOnceMonFinishedMoving(u8 taskId) +static void Task_OpenInfoScreenAfterMonMovement(u8 taskId) { if (gSprites[sPokedexView->selectedMonSpriteId].pos1.x == 48 && gSprites[sPokedexView->selectedMonSpriteId].pos1.y == 56) { - sPokedexView->unk64B = sPokedexView->unk64A; - gTasks[taskId].data[0] = SetupInfoScreen(&sPokedexView->pokedexList[sPokedexView->selectedPokemon], sPokedexView->selectedMonSpriteId); - gTasks[taskId].func = sub_80BBC74; + sPokedexView->currentPageBackup = sPokedexView->currentPage; + gTasks[taskId].tTaskId = LoadInfoScreen(&sPokedexView->pokedexList[sPokedexView->selectedPokemon], sPokedexView->selectedMonSpriteId); + gTasks[taskId].func = Task_WaitForExitInfoScreen; } } -void sub_80BBC74(u8 taskId) +static void Task_WaitForExitInfoScreen(u8 taskId) { - if (gTasks[gTasks[taskId].data[0]].isActive) + if (gTasks[gTasks[taskId].tTaskId].isActive) { - if (sPokedexView->unk64A == 1 && !sub_80BE9C4(gTasks[taskId].data[0]) && UpdateSelectedMon()) - sub_80BE9F8(&sPokedexView->pokedexList[sPokedexView->selectedPokemon], gTasks[taskId].data[0]); + if (sPokedexView->currentPage == PAGE_INFO && !IsInfoScreenScrolling(gTasks[taskId].tTaskId) && TryDoInfoScreenScroll()) + sub_80BE9F8(&sPokedexView->pokedexList[sPokedexView->selectedPokemon], gTasks[taskId].tTaskId); } else { - gUnknown_02039B50 = sPokedexView->selectedPokemon; - gUnknown_02039B52 = sPokedexView->unk62C; - gTasks[taskId].func = sub_80BB78C; + sLastSelectedPokemon = sPokedexView->selectedPokemon; + sPokeBallRotation = sPokedexView->pokeBallRotation; + gTasks[taskId].func = Task_OpenPokedexMainPage; } } -void sub_80BBD1C(u8 taskId) +static void Task_WaitForExitSearch(u8 taskId) { - if (!gTasks[gTasks[taskId].data[0]].isActive) + if (!gTasks[gTasks[taskId].tTaskId].isActive) { ClearMonSprites(); - if (sPokedexView->unk64E != 0) + + // Search produced results + if (sPokedexView->screenSwitchState != 0) { sPokedexView->selectedPokemon = 0; - sPokedexView->unk62C = 0x40; - gTasks[taskId].func = sub_80BBE70; + sPokedexView->pokeBallRotation = POKEBALL_ROTATION_TOP; + gTasks[taskId].func = Task_OpenSearchResults; } + // Search didn't produce results else { - sPokedexView->unk62C = sPokedexView->unk62A; - sPokedexView->selectedPokemon = sPokedexView->unk610; - sPokedexView->dexMode = sPokedexView->unk614; + sPokedexView->pokeBallRotation = sPokedexView->pokeBallRotationBackup; + sPokedexView->selectedPokemon = sPokedexView->selectedPokemonBackup; + sPokedexView->dexMode = sPokedexView->dexModeBackup; if (!IsNationalPokedexEnabled()) sPokedexView->dexMode = DEX_MODE_HOENN; - sPokedexView->dexOrder = sPokedexView->unk618; - gTasks[taskId].func = sub_80BB78C; + sPokedexView->dexOrder = sPokedexView->dexOrderBackup; + gTasks[taskId].func = Task_OpenPokedexMainPage; } } } -void sub_80BBDE8(u8 taskId) +static void Task_ClosePokedex(u8 taskId) { if (!gPaletteFade.active) { @@ -1604,14 +1854,14 @@ void sub_80BBDE8(u8 taskId) } } -void sub_80BBE70(u8 taskId) +static void Task_OpenSearchResults(u8 taskId) { - sPokedexView->unk64C_1 = TRUE; - if (sub_80BC514(3)) - gTasks[taskId].func = sub_80BBEB8; + sPokedexView->isSearchResults = TRUE; + if (LoadPokedexListPage(PAGE_SEARCH_RESULTS)) + gTasks[taskId].func = Task_HandleSearchResultsInput; } -void sub_80BBEB8(u8 taskId) +static void Task_HandleSearchResultsInput(u8 taskId) { SetGpuReg(REG_OFFSET_BG0VOFS, sPokedexView->menuY); @@ -1627,52 +1877,52 @@ void sub_80BBEB8(u8 taskId) UpdateSelectedMonSpriteId(); a = (1 << (gSprites[sPokedexView->selectedMonSpriteId].oam.paletteNum + 16)); - gSprites[sPokedexView->selectedMonSpriteId].callback = MoveMonIntoPosition; + gSprites[sPokedexView->selectedMonSpriteId].callback = SpriteCB_MoveMonForInfoScreen; BeginNormalPaletteFade(~a, 0, 0, 0x10, RGB_BLACK); - gTasks[taskId].func = sub_80BC2D4; + gTasks[taskId].func = Task_OpenSearchResultsInfoScreenAfterMonMovement; PlaySE(SE_PIN); FreeWindowAndBgBuffers(); } else if (gMain.newKeys & START_BUTTON) { sPokedexView->menuY = 0; - sPokedexView->menuIsOpen = 1; + sPokedexView->menuIsOpen = TRUE; sPokedexView->menuCursorPos = 0; - gTasks[taskId].func = HandleButtonPress_StartMenu; + gTasks[taskId].func = Task_HandleSearchResultsStartMenuInput; PlaySE(SE_SELECT); } else if (gMain.newKeys & SELECT_BUTTON) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); - gTasks[taskId].data[0] = LoadSearchMenu(); - sPokedexView->unk64E = 0; - gTasks[taskId].func = sub_80BBD1C; + gTasks[taskId].tTaskId = LoadSearchMenu(); + sPokedexView->screenSwitchState = 0; + gTasks[taskId].func = Task_WaitForExitSearch; PlaySE(SE_PC_LOGIN); FreeWindowAndBgBuffers(); } else if (gMain.newKeys & B_BUTTON) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); - gTasks[taskId].func = sub_80BC3DC; + gTasks[taskId].func = Task_ReturnToPokedexFromSearchResults; PlaySE(SE_PC_OFF); } else { //Handle D-pad - sPokedexView->selectedPokemon = sub_80BD69C(sPokedexView->selectedPokemon, 0xE); - if (sPokedexView->unk62E) - gTasks[taskId].func = sub_80BC0A8; + sPokedexView->selectedPokemon = TryDoPokedexScroll(sPokedexView->selectedPokemon, 0xE); + if (sPokedexView->scrollTimer) + gTasks[taskId].func = Task_WaitForSearchResultsScroll; } } } -void sub_80BC0A8(u8 taskId) +static void Task_WaitForSearchResultsScroll(u8 taskId) { - if (sub_80BD404(sPokedexView->unk62F, sPokedexView->unk634, sPokedexView->unk636)) - gTasks[taskId].func = sub_80BBEB8; + if (UpdateDexListScroll(sPokedexView->scrollDirection, sPokedexView->scrollMonIncrement, sPokedexView->maxScrollTimer)) + gTasks[taskId].func = Task_HandleSearchResultsInput; } -static void HandleButtonPress_StartMenu(u8 taskId) +static void Task_HandleSearchResultsStartMenuInput(u8 taskId) { SetGpuReg(REG_OFFSET_BG0VOFS, sPokedexView->menuY); @@ -1687,41 +1937,41 @@ static void HandleButtonPress_StartMenu(u8 taskId) switch (sPokedexView->menuCursorPos) { case 0: //BACK TO LIST - default: - gMain.newKeys |= START_BUTTON; - break; - case 1: //LIST TOP - sPokedexView->selectedPokemon = 0; - sPokedexView->unk62C = 0x40; - ClearMonSprites(); - CreateInitialPokemonSprites(sPokedexView->selectedPokemon, 0xE); - gMain.newKeys |= START_BUTTON; - break; - case 2: //LIST BOTTOM - sPokedexView->selectedPokemon = sPokedexView->pokemonListCount - 1; - sPokedexView->unk62C = sPokedexView->pokemonListCount * 16 + 0x30; - ClearMonSprites(); - CreateInitialPokemonSprites(sPokedexView->selectedPokemon, 0xE); - gMain.newKeys |= START_BUTTON; - break; - case 3: //BACK TO POKEDEX - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); - gTasks[taskId].func = sub_80BC3DC; - PlaySE(SE_TRACK_DOOR); - break; - case 4: //CLOSE POKEDEX - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); - gTasks[taskId].func = sub_80BC47C; - PlaySE(SE_PC_OFF); - break; + default: + gMain.newKeys |= START_BUTTON; + break; + case 1: //LIST TOP + sPokedexView->selectedPokemon = 0; + sPokedexView->pokeBallRotation = POKEBALL_ROTATION_TOP; + ClearMonSprites(); + CreateMonSpritesAtPos(sPokedexView->selectedPokemon, 0xE); + gMain.newKeys |= START_BUTTON; + break; + case 2: //LIST BOTTOM + sPokedexView->selectedPokemon = sPokedexView->pokemonListCount - 1; + sPokedexView->pokeBallRotation = sPokedexView->pokemonListCount * 16 + POKEBALL_ROTATION_BOTTOM; + ClearMonSprites(); + CreateMonSpritesAtPos(sPokedexView->selectedPokemon, 0xE); + gMain.newKeys |= START_BUTTON; + break; + case 3: //BACK TO POKEDEX + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); + gTasks[taskId].func = Task_ReturnToPokedexFromSearchResults; + PlaySE(SE_TRACK_DOOR); + break; + case 4: //CLOSE POKEDEX + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); + gTasks[taskId].func = Task_ClosePokedexFromSearchResultsStartMenu; + PlaySE(SE_PC_OFF); + break; } } //Exit menu when Start or B is pressed if (gMain.newKeys & (START_BUTTON | B_BUTTON)) { - sPokedexView->menuIsOpen = 0; - gTasks[taskId].func = sub_80BBEB8; + sPokedexView->menuIsOpen = FALSE; + gTasks[taskId].func = Task_HandleSearchResultsInput; PlaySE(SE_SELECT); } else if ((gMain.newAndRepeatedKeys & DPAD_UP) && sPokedexView->menuCursorPos) @@ -1729,7 +1979,7 @@ static void HandleButtonPress_StartMenu(u8 taskId) sPokedexView->menuCursorPos--; PlaySE(SE_SELECT); } - else if ((gMain.newAndRepeatedKeys & DPAD_DOWN) && sPokedexView->menuCursorPos <= 3) + else if ((gMain.newAndRepeatedKeys & DPAD_DOWN) && sPokedexView->menuCursorPos < 4) { sPokedexView->menuCursorPos++; PlaySE(SE_SELECT); @@ -1737,162 +1987,165 @@ static void HandleButtonPress_StartMenu(u8 taskId) } } -void sub_80BC2D4(u8 taskId) +static void Task_OpenSearchResultsInfoScreenAfterMonMovement(u8 taskId) { if (gSprites[sPokedexView->selectedMonSpriteId].pos1.x == 48 && gSprites[sPokedexView->selectedMonSpriteId].pos1.y == 56) { - sPokedexView->unk64B = sPokedexView->unk64A; - gTasks[taskId].data[0] = SetupInfoScreen(&sPokedexView->pokedexList[sPokedexView->selectedPokemon], sPokedexView->selectedMonSpriteId); + sPokedexView->currentPageBackup = sPokedexView->currentPage; + gTasks[taskId].tTaskId = LoadInfoScreen(&sPokedexView->pokedexList[sPokedexView->selectedPokemon], sPokedexView->selectedMonSpriteId); sPokedexView->selectedMonSpriteId = -1; - gTasks[taskId].func = sub_80BC360; + gTasks[taskId].func = Task_WaitForExitSearchResultsInfoScreen; } } -void sub_80BC360(u8 taskId) +static void Task_WaitForExitSearchResultsInfoScreen(u8 taskId) { - if (gTasks[gTasks[taskId].data[0]].isActive) + if (gTasks[gTasks[taskId].tTaskId].isActive) { - if (sPokedexView->unk64A == 1 && !sub_80BE9C4(gTasks[taskId].data[0]) && UpdateSelectedMon()) - sub_80BE9F8(&sPokedexView->pokedexList[sPokedexView->selectedPokemon], gTasks[taskId].data[0]); + if (sPokedexView->currentPage == PAGE_INFO && !IsInfoScreenScrolling(gTasks[taskId].tTaskId) && TryDoInfoScreenScroll()) + sub_80BE9F8(&sPokedexView->pokedexList[sPokedexView->selectedPokemon], gTasks[taskId].tTaskId); } else { - gTasks[taskId].func = sub_80BBE70; + gTasks[taskId].func = Task_OpenSearchResults; } } -void sub_80BC3DC(u8 taskId) +static void Task_ReturnToPokedexFromSearchResults(u8 taskId) { if (!gPaletteFade.active) { - sPokedexView->unk62C = sPokedexView->unk62A; - sPokedexView->selectedPokemon = sPokedexView->unk610; - sPokedexView->dexMode = sPokedexView->unk614; + sPokedexView->pokeBallRotation = sPokedexView->pokeBallRotationBackup; + sPokedexView->selectedPokemon = sPokedexView->selectedPokemonBackup; + sPokedexView->dexMode = sPokedexView->dexModeBackup; if (!IsNationalPokedexEnabled()) sPokedexView->dexMode = DEX_MODE_HOENN; - sPokedexView->dexOrder = sPokedexView->unk618; - gTasks[taskId].func = sub_80BB78C; + sPokedexView->dexOrder = sPokedexView->dexOrderBackup; + gTasks[taskId].func = Task_OpenPokedexMainPage; ClearMonSprites(); FreeWindowAndBgBuffers(); } } -void sub_80BC47C(u8 taskId) +static void Task_ClosePokedexFromSearchResultsStartMenu(u8 taskId) { if (!gPaletteFade.active) { - sPokedexView->unk62C = sPokedexView->unk62A; - sPokedexView->selectedPokemon = sPokedexView->unk610; - sPokedexView->dexMode = sPokedexView->unk614; + sPokedexView->pokeBallRotation = sPokedexView->pokeBallRotationBackup; + sPokedexView->selectedPokemon = sPokedexView->selectedPokemonBackup; + sPokedexView->dexMode = sPokedexView->dexModeBackup; if (!IsNationalPokedexEnabled()) sPokedexView->dexMode = DEX_MODE_HOENN; - sPokedexView->dexOrder = sPokedexView->unk618; - gTasks[taskId].func = sub_80BBDE8; + sPokedexView->dexOrder = sPokedexView->dexOrderBackup; + gTasks[taskId].func = Task_ClosePokedex; } } -bool8 sub_80BC514(u8 a) +#undef tTaskId + +// For loading main pokedex page or pokedex search results +static bool8 LoadPokedexListPage(u8 page) { switch (gMain.state) { - case 0: - default: - if (gPaletteFade.active) - return 0; - SetVBlankCallback(NULL); - sPokedexView->unk64A = a; - ResetOtherVideoRegisters(0); - SetGpuReg(REG_OFFSET_BG2VOFS, sPokedexView->initialVOffset); - ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, sPokedex_BgTemplate, 4); - SetBgTilemapBuffer(3, AllocZeroed(0x800)); - SetBgTilemapBuffer(2, AllocZeroed(0x800)); - SetBgTilemapBuffer(1, AllocZeroed(0x800)); - SetBgTilemapBuffer(0, AllocZeroed(0x800)); - DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0); - CopyToBgTilemapBuffer(1, gPokedexTilemap_Main, 0, 0); - CopyToBgTilemapBuffer(3, gPokedexTilemap_MainUnderlay, 0, 0); - if (a == 0) - CopyToBgTilemapBuffer(0, gPokedexTilemap_StartMenu1, 0, 0x280); - else - CopyToBgTilemapBuffer(0, gPokedexTilemap_StartMenu2, 0, 0x280); - ResetPaletteFade(); - if (a == 0) - sPokedexView->unk64C_1 = FALSE; - else - sPokedexView->unk64C_1 = TRUE; - LoadPokedexBgPalette(sPokedexView->unk64C_1); - InitWindows(sPokemonList_WindowTemplate); - DeactivateAllTextPrinters(); - PutWindowTilemap(0); - CopyWindowToVram(0, 3); - gMain.state = 1; - break; - case 1: - ResetSpriteData(); - FreeAllSpritePalettes(); - gReservedSpritePaletteCount = 8; - LoadCompressedSpriteSheet(&sInterfaceSpriteSheet[0]); - LoadSpritePalettes(sInterfaceSpritePalette); - CreateInterfaceSprites(a); - gMain.state++; - break; - case 2: - gMain.state++; - break; - case 3: - if (a == 0) - CreatePokedexList(sPokedexView->dexMode, sPokedexView->dexOrder); - CreateInitialPokemonSprites(sPokedexView->selectedPokemon, 0xE); - sPokedexView->menuIsOpen = 0; - sPokedexView->menuY = 0; - CopyBgTilemapBufferToVram(0); - CopyBgTilemapBufferToVram(1); - CopyBgTilemapBufferToVram(2); - CopyBgTilemapBufferToVram(3); - gMain.state++; - break; - case 4: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); - SetVBlankCallback(sub_80BB370); - gMain.state++; - break; - case 5: - SetGpuReg(REG_OFFSET_WININ, 0x3F3F); - SetGpuReg(REG_OFFSET_WINOUT, 0x1D3F); - SetGpuReg(REG_OFFSET_WIN0H, 0); - SetGpuReg(REG_OFFSET_WIN0V, 0); - SetGpuReg(REG_OFFSET_WIN1H, 0); - SetGpuReg(REG_OFFSET_WIN1V, 0); - SetGpuReg(REG_OFFSET_BLDCNT, 0); - SetGpuReg(REG_OFFSET_BLDALPHA, 0); - SetGpuReg(REG_OFFSET_BLDY, 0); - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON | DISPCNT_OBJWIN_ON); - ShowBg(0); - ShowBg(1); - ShowBg(2); - ShowBg(3); - gMain.state++; - break; - case 6: - if (!gPaletteFade.active) - { - gMain.state = 0; - return TRUE; - } - break; + case 0: + default: + if (gPaletteFade.active) + return 0; + SetVBlankCallback(NULL); + sPokedexView->currentPage = page; + ResetOtherVideoRegisters(0); + SetGpuReg(REG_OFFSET_BG2VOFS, sPokedexView->initialVOffset); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, sPokedex_BgTemplate, ARRAY_COUNT(sPokedex_BgTemplate)); + SetBgTilemapBuffer(3, AllocZeroed(0x800)); + SetBgTilemapBuffer(2, AllocZeroed(0x800)); + SetBgTilemapBuffer(1, AllocZeroed(0x800)); + SetBgTilemapBuffer(0, AllocZeroed(0x800)); + DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0); + CopyToBgTilemapBuffer(1, gPokedexList_Tilemap, 0, 0); + CopyToBgTilemapBuffer(3, gPokedexListUnderlay_Tilemap, 0, 0); + if (page == PAGE_MAIN) + CopyToBgTilemapBuffer(0, gPokedexStartMenuMain_Tilemap, 0, 0x280); + else + CopyToBgTilemapBuffer(0, gPokedexStartMenuSearchResults_Tilemap, 0, 0x280); + ResetPaletteFade(); + if (page == PAGE_MAIN) + sPokedexView->isSearchResults = FALSE; + else + sPokedexView->isSearchResults = TRUE; + LoadPokedexBgPalette(sPokedexView->isSearchResults); + InitWindows(sPokemonList_WindowTemplate); + DeactivateAllTextPrinters(); + PutWindowTilemap(0); + CopyWindowToVram(0, 3); + gMain.state = 1; + break; + case 1: + ResetSpriteData(); + FreeAllSpritePalettes(); + gReservedSpritePaletteCount = 8; + LoadCompressedSpriteSheet(&sInterfaceSpriteSheet[0]); + LoadSpritePalettes(sInterfaceSpritePalette); + CreateInterfaceSprites(page); + gMain.state++; + break; + case 2: + gMain.state++; + break; + case 3: + if (page == PAGE_MAIN) + CreatePokedexList(sPokedexView->dexMode, sPokedexView->dexOrder); + CreateMonSpritesAtPos(sPokedexView->selectedPokemon, 0xE); + sPokedexView->menuIsOpen = FALSE; + sPokedexView->menuY = 0; + CopyBgTilemapBufferToVram(0); + CopyBgTilemapBufferToVram(1); + CopyBgTilemapBufferToVram(2); + CopyBgTilemapBufferToVram(3); + gMain.state++; + break; + case 4: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); + SetVBlankCallback(VBlankCB_Pokedex); + gMain.state++; + break; + case 5: + SetGpuReg(REG_OFFSET_WININ, 0x3F3F); + SetGpuReg(REG_OFFSET_WINOUT, 0x1D3F); + SetGpuReg(REG_OFFSET_WIN0H, 0); + SetGpuReg(REG_OFFSET_WIN0V, 0); + SetGpuReg(REG_OFFSET_WIN1H, 0); + SetGpuReg(REG_OFFSET_WIN1V, 0); + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON | DISPCNT_OBJWIN_ON); + ShowBg(0); + ShowBg(1); + ShowBg(2); + ShowBg(3); + gMain.state++; + break; + case 6: + if (!gPaletteFade.active) + { + gMain.state = 0; + return TRUE; + } + break; } return FALSE; } -static void LoadPokedexBgPalette(u8 a) +static void LoadPokedexBgPalette(bool8 isSearchResults) { - if (a == 1) - LoadPalette(gPokedexHoennBg_Pal + 1, 1, 0xBE); + if (isSearchResults == TRUE) + LoadPalette(gPokedexSearchResults_Pal + 1, 1, 0xBE); else if (!IsNationalPokedexEnabled()) - LoadPalette(gPokedexText_Pal + 1, 1, 0xBE); + LoadPalette(gPokedexBgHoenn_Pal + 1, 1, 0xBE); else - LoadPalette(gPokedexNationalBg_Pal + 1, 1, 0xBE); + LoadPalette(gPokedexBgNational_Pal + 1, 1, 0xBE); LoadPalette(GetOverworldTextboxPalettePtr(), 0xF0, 32); } @@ -1915,7 +2168,7 @@ static void FreeWindowAndBgBuffers(void) Free(tilemapBuffer); } -static void CreatePokedexList(u8 dexMode, u8 sortMode) +static void CreatePokedexList(u8 dexMode, u8 order) { u16 vars[3]; //I have no idea why three regular variables are stored in an array, but whatever. #define temp_dexCount vars[0] @@ -1927,134 +2180,134 @@ static void CreatePokedexList(u8 dexMode, u8 sortMode) switch (dexMode) { - default: - case DEX_MODE_HOENN: + default: + case DEX_MODE_HOENN: + temp_dexCount = HOENN_DEX_COUNT; + temp_isHoennDex = TRUE; + break; + case DEX_MODE_NATIONAL: + if (IsNationalPokedexEnabled()) + { + temp_dexCount = NATIONAL_DEX_COUNT; + temp_isHoennDex = FALSE; + } + else + { temp_dexCount = HOENN_DEX_COUNT; temp_isHoennDex = TRUE; - break; - case DEX_MODE_NATIONAL: - if (IsNationalPokedexEnabled()) - { - temp_dexCount = NATIONAL_DEX_COUNT; - temp_isHoennDex = FALSE; - } - else - { - temp_dexCount = HOENN_DEX_COUNT; - temp_isHoennDex = TRUE; - } - break; + } + break; } - switch (sortMode) + switch (order) { - case SORT_NUMERICAL: - if (temp_isHoennDex) + case ORDER_NUMERICAL: + if (temp_isHoennDex) + { + for (i = 0; i < temp_dexCount; i++) { - for (i = 0; i < temp_dexCount; i++) - { - temp_dexNum = HoennToNationalOrder(i + 1); - sPokedexView->pokedexList[i].dexNum = temp_dexNum; - sPokedexView->pokedexList[i].seen = GetSetPokedexFlag(temp_dexNum, FLAG_GET_SEEN); - sPokedexView->pokedexList[i].owned = GetSetPokedexFlag(temp_dexNum, FLAG_GET_CAUGHT); - if (sPokedexView->pokedexList[i].seen) - sPokedexView->pokemonListCount = i + 1; - } + temp_dexNum = HoennToNationalOrder(i + 1); + sPokedexView->pokedexList[i].dexNum = temp_dexNum; + sPokedexView->pokedexList[i].seen = GetSetPokedexFlag(temp_dexNum, FLAG_GET_SEEN); + sPokedexView->pokedexList[i].owned = GetSetPokedexFlag(temp_dexNum, FLAG_GET_CAUGHT); + if (sPokedexView->pokedexList[i].seen) + sPokedexView->pokemonListCount = i + 1; } - else - { - bool32 r10; - s16 r5; + } + else + { + bool32 r10; + s16 r5; - r10 = r5 = i = 0; - for (i = 0; i < temp_dexCount; i++) - { - temp_dexNum = i + 1; - if (GetSetPokedexFlag(temp_dexNum, FLAG_GET_SEEN)) - r10 = 1; - if (r10) - { - asm(""); //Needed to match for some reason - sPokedexView->pokedexList[r5].dexNum = temp_dexNum; - sPokedexView->pokedexList[r5].seen = GetSetPokedexFlag(temp_dexNum, FLAG_GET_SEEN); - sPokedexView->pokedexList[r5].owned = GetSetPokedexFlag(temp_dexNum, FLAG_GET_CAUGHT); - if (sPokedexView->pokedexList[r5].seen) - sPokedexView->pokemonListCount = r5 + 1; - r5++; - } - } - } - break; - case SORT_ALPHABETICAL: - for (i = 0; i < POKEMON_SLOTS_NUMBER - 1; i++) + r10 = r5 = i = 0; + for (i = 0; i < temp_dexCount; i++) { - temp_dexNum = gPokedexOrder_Alphabetical[i]; - - if (NationalToHoennOrder(temp_dexNum) <= temp_dexCount && GetSetPokedexFlag(temp_dexNum, FLAG_GET_SEEN)) + temp_dexNum = i + 1; + if (GetSetPokedexFlag(temp_dexNum, FLAG_GET_SEEN)) + r10 = 1; + if (r10) { - sPokedexView->pokedexList[sPokedexView->pokemonListCount].dexNum = temp_dexNum; - sPokedexView->pokedexList[sPokedexView->pokemonListCount].seen = TRUE; - sPokedexView->pokedexList[sPokedexView->pokemonListCount].owned = GetSetPokedexFlag(temp_dexNum, FLAG_GET_CAUGHT); - sPokedexView->pokemonListCount++; + asm(""); //Needed to match for some reason + sPokedexView->pokedexList[r5].dexNum = temp_dexNum; + sPokedexView->pokedexList[r5].seen = GetSetPokedexFlag(temp_dexNum, FLAG_GET_SEEN); + sPokedexView->pokedexList[r5].owned = GetSetPokedexFlag(temp_dexNum, FLAG_GET_CAUGHT); + if (sPokedexView->pokedexList[r5].seen) + sPokedexView->pokemonListCount = r5 + 1; + r5++; } } - break; - case SORT_HEAVIEST: - for (i = NATIONAL_DEX_COUNT - 1; i >= 0; i--) + } + break; + case ORDER_ALPHABETICAL: + for (i = 0; i < NUM_SPECIES - 1; i++) + { + temp_dexNum = gPokedexOrder_Alphabetical[i]; + + if (NationalToHoennOrder(temp_dexNum) <= temp_dexCount && GetSetPokedexFlag(temp_dexNum, FLAG_GET_SEEN)) { - temp_dexNum = gPokedexOrder_Weight[i]; - - if (NationalToHoennOrder(temp_dexNum) <= temp_dexCount && GetSetPokedexFlag(temp_dexNum, FLAG_GET_CAUGHT)) - { - sPokedexView->pokedexList[sPokedexView->pokemonListCount].dexNum = temp_dexNum; - sPokedexView->pokedexList[sPokedexView->pokemonListCount].seen = TRUE; - sPokedexView->pokedexList[sPokedexView->pokemonListCount].owned = TRUE; - sPokedexView->pokemonListCount++; - } + sPokedexView->pokedexList[sPokedexView->pokemonListCount].dexNum = temp_dexNum; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].seen = TRUE; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].owned = GetSetPokedexFlag(temp_dexNum, FLAG_GET_CAUGHT); + sPokedexView->pokemonListCount++; } - break; - case SORT_LIGHTEST: - for (i = 0; i < NATIONAL_DEX_COUNT; i++) + } + break; + case ORDER_HEAVIEST: + for (i = NATIONAL_DEX_COUNT - 1; i >= 0; i--) + { + temp_dexNum = gPokedexOrder_Weight[i]; + + if (NationalToHoennOrder(temp_dexNum) <= temp_dexCount && GetSetPokedexFlag(temp_dexNum, FLAG_GET_CAUGHT)) { - temp_dexNum = gPokedexOrder_Weight[i]; - - if (NationalToHoennOrder(temp_dexNum) <= temp_dexCount && GetSetPokedexFlag(temp_dexNum, FLAG_GET_CAUGHT)) - { - sPokedexView->pokedexList[sPokedexView->pokemonListCount].dexNum = temp_dexNum; - sPokedexView->pokedexList[sPokedexView->pokemonListCount].seen = TRUE; - sPokedexView->pokedexList[sPokedexView->pokemonListCount].owned = TRUE; - sPokedexView->pokemonListCount++; - } + sPokedexView->pokedexList[sPokedexView->pokemonListCount].dexNum = temp_dexNum; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].seen = TRUE; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].owned = TRUE; + sPokedexView->pokemonListCount++; } - break; - case SORT_TALLEST: - for (i = NATIONAL_DEX_COUNT - 1; i >= 0; i--) + } + break; + case ORDER_LIGHTEST: + for (i = 0; i < NATIONAL_DEX_COUNT; i++) + { + temp_dexNum = gPokedexOrder_Weight[i]; + + if (NationalToHoennOrder(temp_dexNum) <= temp_dexCount && GetSetPokedexFlag(temp_dexNum, FLAG_GET_CAUGHT)) { - temp_dexNum = gPokedexOrder_Height[i]; - - if (NationalToHoennOrder(temp_dexNum) <= temp_dexCount && GetSetPokedexFlag(temp_dexNum, FLAG_GET_CAUGHT)) - { - sPokedexView->pokedexList[sPokedexView->pokemonListCount].dexNum = temp_dexNum; - sPokedexView->pokedexList[sPokedexView->pokemonListCount].seen = TRUE; - sPokedexView->pokedexList[sPokedexView->pokemonListCount].owned = TRUE; - sPokedexView->pokemonListCount++; - } + sPokedexView->pokedexList[sPokedexView->pokemonListCount].dexNum = temp_dexNum; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].seen = TRUE; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].owned = TRUE; + sPokedexView->pokemonListCount++; } - break; - case SORT_SMALLEST: - for (i = 0; i < NATIONAL_DEX_COUNT; i++) + } + break; + case ORDER_TALLEST: + for (i = NATIONAL_DEX_COUNT - 1; i >= 0; i--) + { + temp_dexNum = gPokedexOrder_Height[i]; + + if (NationalToHoennOrder(temp_dexNum) <= temp_dexCount && GetSetPokedexFlag(temp_dexNum, FLAG_GET_CAUGHT)) { - temp_dexNum = gPokedexOrder_Height[i]; - - if (NationalToHoennOrder(temp_dexNum) <= temp_dexCount && GetSetPokedexFlag(temp_dexNum, FLAG_GET_CAUGHT)) - { - sPokedexView->pokedexList[sPokedexView->pokemonListCount].dexNum = temp_dexNum; - sPokedexView->pokedexList[sPokedexView->pokemonListCount].seen = TRUE; - sPokedexView->pokedexList[sPokedexView->pokemonListCount].owned = TRUE; - sPokedexView->pokemonListCount++; - } + sPokedexView->pokedexList[sPokedexView->pokemonListCount].dexNum = temp_dexNum; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].seen = TRUE; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].owned = TRUE; + sPokedexView->pokemonListCount++; } - break; + } + break; + case ORDER_SMALLEST: + for (i = 0; i < NATIONAL_DEX_COUNT; i++) + { + temp_dexNum = gPokedexOrder_Height[i]; + + if (NationalToHoennOrder(temp_dexNum) <= temp_dexCount && GetSetPokedexFlag(temp_dexNum, FLAG_GET_CAUGHT)) + { + sPokedexView->pokedexList[sPokedexView->pokemonListCount].dexNum = temp_dexNum; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].seen = TRUE; + sPokedexView->pokedexList[sPokedexView->pokemonListCount].owned = TRUE; + sPokedexView->pokemonListCount++; + } + } + break; } for (i = sPokedexView->pokemonListCount; i < NATIONAL_DEX_COUNT; i++) @@ -2069,118 +2322,119 @@ static void PrintMonDexNumAndName(u8 windowId, u8 fontId, const u8* str, u8 left { u8 color[3]; - color[0] = 0; - color[1] = 15; - color[2] = 3; + color[0] = TEXT_COLOR_TRANSPARENT; + color[1] = TEXT_DYNAMIC_COLOR_6; + color[2] = TEXT_COLOR_LIGHT_GREY; AddTextPrinterParameterized4(windowId, fontId, left * 8, (top * 8) + 1, 0, 0, color, -1, str); } -static void CreateMonListEntry(u8 direction, u16 b, u16 c) +// u16 ignored is passed but never used +static void CreateMonListEntry(u8 position, u16 b, u16 ignored) { - s16 _b; + s16 entryNum; u16 i; - u16 r2; + u16 vOffset; - switch (direction) + switch (position) { - case 0: // Initial - default: - _b = b - 5; - for (i = 0; i <= 10; i++) + case 0: // Initial + default: + entryNum = b - 5; + for (i = 0; i <= 10; i++) + { + if (entryNum < 0 || entryNum >= NATIONAL_DEX_COUNT || sPokedexView->pokedexList[entryNum].dexNum == 0xFFFF) { - if (_b < 0 || _b >= NATIONAL_DEX_COUNT || sPokedexView->pokedexList[_b].dexNum == 0xFFFF) - { - ClearMonListEntry(0x11, i * 2, c); - } - else - { - ClearMonListEntry(0x11, i * 2, c); - if (sPokedexView->pokedexList[_b].seen) - { - CreateMonDexNum(_b, 0x12, i * 2, c); - CreateCaughtBall(sPokedexView->pokedexList[_b].owned, 0x11, i * 2, c); - CreateMonName(sPokedexView->pokedexList[_b].dexNum, 0x16, i * 2); - } - else - { - CreateMonDexNum(_b, 0x12, i * 2, c); - CreateCaughtBall(0, 0x11, i * 2, c); - CreateMonName(0, 0x16, i * 2); - } - } - _b++; - } - break; - case 1: // Up - _b = b - 5; - if (_b < 0 || _b >= NATIONAL_DEX_COUNT || sPokedexView->pokedexList[_b].dexNum == 0xFFFF) - { - ClearMonListEntry(0x11, sPokedexView->unk630 * 2, c); + ClearMonListEntry(17, i * 2, ignored); } else { - ClearMonListEntry(0x11, sPokedexView->unk630 * 2, c); - if (sPokedexView->pokedexList[_b].seen) + ClearMonListEntry(17, i * 2, ignored); + if (sPokedexView->pokedexList[entryNum].seen) { - CreateMonDexNum(_b, 0x12, sPokedexView->unk630 * 2, c); - CreateCaughtBall(sPokedexView->pokedexList[_b].owned, 0x11, sPokedexView->unk630 * 2, c); - CreateMonName(sPokedexView->pokedexList[_b].dexNum, 0x16, sPokedexView->unk630 * 2); + CreateMonDexNum(entryNum, 0x12, i * 2, ignored); + CreateCaughtBall(sPokedexView->pokedexList[entryNum].owned, 0x11, i * 2, ignored); + CreateMonName(sPokedexView->pokedexList[entryNum].dexNum, 0x16, i * 2); } else { - CreateMonDexNum(_b, 0x12, sPokedexView->unk630 * 2, c); - CreateCaughtBall(0, 0x11, sPokedexView->unk630 * 2, c); - CreateMonName(0, 0x16, sPokedexView->unk630 * 2); + CreateMonDexNum(entryNum, 0x12, i * 2, ignored); + CreateCaughtBall(FALSE, 0x11, i * 2, ignored); + CreateMonName(0, 0x16, i * 2); } } - break; - case 2: // Down - _b = b + 5; - r2 = sPokedexView->unk630 + 10; - if (r2 > 15) - r2 -= 16; - if (_b < 0 || _b >= NATIONAL_DEX_COUNT || sPokedexView->pokedexList[_b].dexNum == 0xFFFF) - ClearMonListEntry(0x11, r2 * 2, c); + entryNum++; + } + break; + case 1: // Up + entryNum = b - 5; + if (entryNum < 0 || entryNum >= NATIONAL_DEX_COUNT || sPokedexView->pokedexList[entryNum].dexNum == 0xFFFF) + { + ClearMonListEntry(17, sPokedexView->listVOffset * 2, ignored); + } + else + { + ClearMonListEntry(17, sPokedexView->listVOffset * 2, ignored); + if (sPokedexView->pokedexList[entryNum].seen) + { + CreateMonDexNum(entryNum, 18, sPokedexView->listVOffset * 2, ignored); + CreateCaughtBall(sPokedexView->pokedexList[entryNum].owned, 0x11, sPokedexView->listVOffset * 2, ignored); + CreateMonName(sPokedexView->pokedexList[entryNum].dexNum, 0x16, sPokedexView->listVOffset * 2); + } else { - ClearMonListEntry(0x11, r2 * 2, c); - if (sPokedexView->pokedexList[_b].seen) - { - CreateMonDexNum(_b, 0x12, r2 * 2, c); - CreateCaughtBall(sPokedexView->pokedexList[_b].owned, 0x11, r2 * 2, c); - CreateMonName(sPokedexView->pokedexList[_b].dexNum, 0x16, r2 * 2); - } - else - { - CreateMonDexNum(_b, 0x12, r2 * 2, c); - CreateCaughtBall(0, 0x11, r2 * 2, c); - CreateMonName(0, 0x16, r2 * 2); - } + CreateMonDexNum(entryNum, 18, sPokedexView->listVOffset * 2, ignored); + CreateCaughtBall(FALSE, 17, sPokedexView->listVOffset * 2, ignored); + CreateMonName(0, 0x16, sPokedexView->listVOffset * 2); } - break; + } + break; + case 2: // Down + entryNum = b + 5; + vOffset = sPokedexView->listVOffset + 10; + if (vOffset >= LIST_SCROLL_STEP) + vOffset -= LIST_SCROLL_STEP; + if (entryNum < 0 || entryNum >= NATIONAL_DEX_COUNT || sPokedexView->pokedexList[entryNum].dexNum == 0xFFFF) + ClearMonListEntry(17, vOffset * 2, ignored); + else + { + ClearMonListEntry(17, vOffset * 2, ignored); + if (sPokedexView->pokedexList[entryNum].seen) + { + CreateMonDexNum(entryNum, 18, vOffset * 2, ignored); + CreateCaughtBall(sPokedexView->pokedexList[entryNum].owned, 0x11, vOffset * 2, ignored); + CreateMonName(sPokedexView->pokedexList[entryNum].dexNum, 0x16, vOffset * 2); + } + else + { + CreateMonDexNum(entryNum, 18, vOffset * 2, ignored); + CreateCaughtBall(FALSE, 0x11, vOffset * 2, ignored); + CreateMonName(0, 0x16, vOffset * 2); + } + } + break; } CopyWindowToVram(0, 2); } -static void CreateMonDexNum(u16 a, u8 left, u8 top, u16 unused) +static void CreateMonDexNum(u16 entryNum, u8 left, u8 top, u16 unused) { u8 text[6]; - u16 r6; + u16 dexNum; - memcpy(text, sText_No000, 6); - r6 = sPokedexView->pokedexList[a].dexNum; + memcpy(text, sText_No000, ARRAY_COUNT(text)); + dexNum = sPokedexView->pokedexList[entryNum].dexNum; if (sPokedexView->dexMode == DEX_MODE_HOENN) - r6 = NationalToHoennOrder(r6); - text[2] = CHAR_0 + r6 / 100; - text[3] = CHAR_0 + (r6 % 100) / 10; - text[4] = CHAR_0 + (r6 % 100) % 10; + dexNum = NationalToHoennOrder(dexNum); + text[2] = CHAR_0 + dexNum / 100; + text[3] = CHAR_0 + (dexNum % 100) / 10; + text[4] = CHAR_0 + (dexNum % 100) % 10; PrintMonDexNumAndName(0, 7, text, left, top); } -static void CreateCaughtBall(u16 a, u8 x, u8 y, u16 unused) +static void CreateCaughtBall(bool16 owned, u8 x, u8 y, u16 unused) { - if (a) - BlitBitmapToWindow(0, gUnknown_0855D2BE, x * 8, y * 8, 8, 16); + if (owned) + BlitBitmapToWindow(0, sCaughtBall_Gfx, x * 8, y * 8, 8, 16); else FillWindowPixelRect(0, PIXEL_FILL(0), x * 8, y * 8, 8, 16); } @@ -2203,190 +2457,196 @@ static void ClearMonListEntry(u8 x, u8 y, u16 unused) FillWindowPixelRect(0, PIXEL_FILL(0), x * 8, y * 8, 0x60, 16); } -static void CreateInitialPokemonSprites(u16 selectedMon, u16 b) +// u16 ignored is passed but never used +static void CreateMonSpritesAtPos(u16 selectedMon, u16 ignored) { u8 i; - u16 unk; + u16 dexNum; u8 spriteId; gPaletteFade.bufferTransferDisabled = TRUE; - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_MONS_ON_SCREEN; i++) sPokedexView->monSpriteIds[i] = 0xFFFF; sPokedexView->selectedMonSpriteId = 0xFFFF; - unk = GetPokemonSpriteToDisplay(selectedMon - 1); - if (unk != 0xFFFF) + // Create top mon sprite + dexNum = GetPokemonSpriteToDisplay(selectedMon - 1); + if (dexNum != 0xFFFF) { - spriteId = sub_80BDACC(unk, 0x60, 0x50); - gSprites[spriteId].callback = sub_80BE4E0; + spriteId = CreatePokedexMonSprite(dexNum, 0x60, 0x50); + gSprites[spriteId].callback = SpriteCB_PokedexListMonSprite; gSprites[spriteId].data[5] = -32; } - unk = GetPokemonSpriteToDisplay(selectedMon); - if (unk != 0xFFFF) + // Create mid mon sprite + dexNum = GetPokemonSpriteToDisplay(selectedMon); + if (dexNum != 0xFFFF) { - spriteId = sub_80BDACC(unk, 0x60, 0x50); - gSprites[spriteId].callback = sub_80BE4E0; + spriteId = CreatePokedexMonSprite(dexNum, 0x60, 0x50); + gSprites[spriteId].callback = SpriteCB_PokedexListMonSprite; gSprites[spriteId].data[5] = 0; } - unk = GetPokemonSpriteToDisplay(selectedMon + 1); - if (unk != 0xFFFF) + // Create bottom mon sprite + dexNum = GetPokemonSpriteToDisplay(selectedMon + 1); + if (dexNum != 0xFFFF) { - spriteId = sub_80BDACC(unk, 0x60, 0x50); - gSprites[spriteId].callback = sub_80BE4E0; + spriteId = CreatePokedexMonSprite(dexNum, 0x60, 0x50); + gSprites[spriteId].callback = SpriteCB_PokedexListMonSprite; gSprites[spriteId].data[5] = 32; } - CreateMonListEntry(0, selectedMon, b); + CreateMonListEntry(0, selectedMon, ignored); SetGpuReg(REG_OFFSET_BG2VOFS, sPokedexView->initialVOffset); - sPokedexView->unk630 = 0; - sPokedexView->unk632 = 0; + sPokedexView->listVOffset = 0; + sPokedexView->listMovingVOffset = 0; gPaletteFade.bufferTransferDisabled = FALSE; } -bool8 sub_80BD404(u8 a, u8 b, u8 c) +static bool8 UpdateDexListScroll(u8 direction, u8 monMoveIncrement, u8 scrollTimerMax) { u16 i; - u8 foo; + u8 step; - if (sPokedexView->unk62E) + if (sPokedexView->scrollTimer) { - sPokedexView->unk62E--; - switch (a) + sPokedexView->scrollTimer--; + switch (direction) { - case 1: - for (i = 0; i < 4; i++) - { - if (sPokedexView->monSpriteIds[i] != 0xFFFF) - gSprites[sPokedexView->monSpriteIds[i]].data[5] += b; - } - foo = 16 * (c - sPokedexView->unk62E) / c; - SetGpuReg(REG_OFFSET_BG2VOFS, sPokedexView->initialVOffset + sPokedexView->unk632 * 16 - foo); - sPokedexView->unk62C -= sPokedexView->unk628; - break; - case 2: - for (i = 0; i < 4; i++) - { - if (sPokedexView->monSpriteIds[i] != 0xFFFF) - gSprites[sPokedexView->monSpriteIds[i]].data[5] -= b; - } - foo = 16 * (c - sPokedexView->unk62E) / c; - SetGpuReg(REG_OFFSET_BG2VOFS, sPokedexView->initialVOffset + sPokedexView->unk632 * 16 + foo); - sPokedexView->unk62C += sPokedexView->unk628; - break; + case 1: // Up + for (i = 0; i < MAX_MONS_ON_SCREEN; i++) + { + if (sPokedexView->monSpriteIds[i] != 0xFFFF) + gSprites[sPokedexView->monSpriteIds[i]].data[5] += monMoveIncrement; + } + step = LIST_SCROLL_STEP * (scrollTimerMax - sPokedexView->scrollTimer) / scrollTimerMax; + SetGpuReg(REG_OFFSET_BG2VOFS, sPokedexView->initialVOffset + sPokedexView->listMovingVOffset * LIST_SCROLL_STEP - step); + sPokedexView->pokeBallRotation -= sPokedexView->pokeBallRotationStep; + break; + case 2: // Down + for (i = 0; i < MAX_MONS_ON_SCREEN; i++) + { + if (sPokedexView->monSpriteIds[i] != 0xFFFF) + gSprites[sPokedexView->monSpriteIds[i]].data[5] -= monMoveIncrement; + } + step = LIST_SCROLL_STEP * (scrollTimerMax - sPokedexView->scrollTimer) / scrollTimerMax; + SetGpuReg(REG_OFFSET_BG2VOFS, sPokedexView->initialVOffset + sPokedexView->listMovingVOffset * LIST_SCROLL_STEP + step); + sPokedexView->pokeBallRotation += sPokedexView->pokeBallRotationStep; + break; } return FALSE; } else { - SetGpuReg(REG_OFFSET_BG2VOFS, sPokedexView->initialVOffset + sPokedexView->unk630 * 16); + SetGpuReg(REG_OFFSET_BG2VOFS, sPokedexView->initialVOffset + sPokedexView->listVOffset * LIST_SCROLL_STEP); return TRUE; } } -static void CreateNewPokemonSprite(u8 direction, u16 selectedMon) +static void CreateScrollingPokemonSprite(u8 direction, u16 selectedMon) { - u16 unk; + u16 dexNum; u8 spriteId; - sPokedexView->unk632 = sPokedexView->unk630; + sPokedexView->listMovingVOffset = sPokedexView->listVOffset; switch (direction) { - case 1: // up - unk = GetPokemonSpriteToDisplay(selectedMon - 1); - if (unk != 0xFFFF) - { - spriteId = sub_80BDACC(unk, 0x60, 0x50); - gSprites[spriteId].callback = sub_80BE4E0; - gSprites[spriteId].data[5] = -64; - } - if (sPokedexView->unk630 > 0) - sPokedexView->unk630--; - else - sPokedexView->unk630 = 15; - break; - case 2: // down - unk = GetPokemonSpriteToDisplay(selectedMon + 1); - if (unk != 0xFFFF) - { - spriteId = sub_80BDACC(unk, 0x60, 0x50); - gSprites[spriteId].callback = sub_80BE4E0; - gSprites[spriteId].data[5] = 0x40; - } - if (sPokedexView->unk630 <= 0xE) - sPokedexView->unk630++; - else - sPokedexView->unk630 = 0; - break; + case 1: // up + dexNum = GetPokemonSpriteToDisplay(selectedMon - 1); + if (dexNum != 0xFFFF) + { + spriteId = CreatePokedexMonSprite(dexNum, 0x60, 0x50); + gSprites[spriteId].callback = SpriteCB_PokedexListMonSprite; + gSprites[spriteId].data[5] = -64; + } + if (sPokedexView->listVOffset > 0) + sPokedexView->listVOffset--; + else + sPokedexView->listVOffset = LIST_SCROLL_STEP - 1; + break; + case 2: // down + dexNum = GetPokemonSpriteToDisplay(selectedMon + 1); + if (dexNum != 0xFFFF) + { + spriteId = CreatePokedexMonSprite(dexNum, 0x60, 0x50); + gSprites[spriteId].callback = SpriteCB_PokedexListMonSprite; + gSprites[spriteId].data[5] = 64; + } + if (sPokedexView->listVOffset < LIST_SCROLL_STEP - 1) + sPokedexView->listVOffset++; + else + sPokedexView->listVOffset = 0; + break; } } -u16 sub_80BD69C(u16 selectedMon, u16 b) +// u16 ignored is passed but never used +static u16 TryDoPokedexScroll(u16 selectedMon, u16 ignored) { - u8 r3; - u8 r5; + u8 scrollTimer; + u8 scrollMonIncrement; u8 i; - u16 r6; - u8 r10 = 0; + u16 startingPos; + u8 scrollDir = 0; if ((gMain.heldKeys & DPAD_UP) && (selectedMon > 0)) { - r10 = 1; - selectedMon = sub_80C0E0C(1, selectedMon, 0, sPokedexView->pokemonListCount - 1); - CreateNewPokemonSprite(1, selectedMon); - CreateMonListEntry(1, selectedMon, b); + scrollDir = 1; + selectedMon = GetNextPosition(1, selectedMon, 0, sPokedexView->pokemonListCount - 1); + CreateScrollingPokemonSprite(1, selectedMon); + CreateMonListEntry(1, selectedMon, ignored); PlaySE(SE_Z_SCROLL); } else if ((gMain.heldKeys & DPAD_DOWN) && (selectedMon < sPokedexView->pokemonListCount - 1)) { - r10 = 2; - selectedMon = sub_80C0E0C(0, selectedMon, 0, sPokedexView->pokemonListCount - 1); - CreateNewPokemonSprite(2, selectedMon); - CreateMonListEntry(2, selectedMon, b); + scrollDir = 2; + selectedMon = GetNextPosition(0, selectedMon, 0, sPokedexView->pokemonListCount - 1); + CreateScrollingPokemonSprite(2, selectedMon); + CreateMonListEntry(2, selectedMon, ignored); PlaySE(SE_Z_SCROLL); } else if ((gMain.newKeys & DPAD_LEFT) && (selectedMon > 0)) { - r6 = selectedMon; + startingPos = selectedMon; for (i = 0; i < 7; i++) - selectedMon = sub_80C0E0C(1, selectedMon, 0, sPokedexView->pokemonListCount - 1); - sPokedexView->unk62C += 16 * (selectedMon - r6); + selectedMon = GetNextPosition(1, selectedMon, 0, sPokedexView->pokemonListCount - 1); + sPokedexView->pokeBallRotation += 16 * (selectedMon - startingPos); ClearMonSprites(); - CreateInitialPokemonSprites(selectedMon, 0xE); + CreateMonSpritesAtPos(selectedMon, 0xE); PlaySE(SE_Z_PAGE); } else if ((gMain.newKeys & DPAD_RIGHT) && (selectedMon < sPokedexView->pokemonListCount - 1)) { - r6 = selectedMon; + startingPos = selectedMon; for (i = 0; i < 7; i++) - selectedMon = sub_80C0E0C(0, selectedMon, 0, sPokedexView->pokemonListCount - 1); - sPokedexView->unk62C += (selectedMon - r6) * 16; + selectedMon = GetNextPosition(0, selectedMon, 0, sPokedexView->pokemonListCount - 1); + sPokedexView->pokeBallRotation += 16 * (selectedMon - startingPos); ClearMonSprites(); - CreateInitialPokemonSprites(selectedMon, 0xE); + CreateMonSpritesAtPos(selectedMon, 0xE); PlaySE(SE_Z_PAGE); } - if (r10 == 0) + if (scrollDir == 0) { - sPokedexView->unk638 = 0; + // Left/right input just snaps up/down, no scrolling + sPokedexView->scrollSpeed = 0; return selectedMon; } - r5 = gUnknown_0855D28C[sPokedexView->unk638 / 4]; - r3 = gUnknown_0855D291[sPokedexView->unk638 / 4]; - sPokedexView->unk62E = r3; - sPokedexView->unk636 = r3; - sPokedexView->unk634 = r5; - sPokedexView->unk62F = r10; - sPokedexView->unk628 = r5 / 2; - sub_80BD404(sPokedexView->unk62F, sPokedexView->unk634, sPokedexView->unk636); - if (sPokedexView->unk638 <= 0xB) - sPokedexView->unk638++; + scrollMonIncrement = sScrollMonIncrements[sPokedexView->scrollSpeed / 4]; + scrollTimer = sScrollTimers[sPokedexView->scrollSpeed / 4]; + sPokedexView->scrollTimer = scrollTimer; + sPokedexView->maxScrollTimer = scrollTimer; + sPokedexView->scrollMonIncrement = scrollMonIncrement; + sPokedexView->scrollDirection = scrollDir; + sPokedexView->pokeBallRotationStep = scrollMonIncrement / 2; + UpdateDexListScroll(sPokedexView->scrollDirection, sPokedexView->scrollMonIncrement, sPokedexView->maxScrollTimer); + if (sPokedexView->scrollSpeed < 12) + sPokedexView->scrollSpeed++; return selectedMon; } @@ -2394,7 +2654,7 @@ static void UpdateSelectedMonSpriteId(void) { u16 i; - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_MONS_ON_SCREEN; i++) { u16 spriteId = sPokedexView->monSpriteIds[i]; @@ -2403,54 +2663,54 @@ static void UpdateSelectedMonSpriteId(void) } } -static bool8 UpdateSelectedMon(void) +static bool8 TryDoInfoScreenScroll(void) { - u16 r2; - u16 r4 = sPokedexView->selectedPokemon; + u16 nextPokemon; + u16 selectedPokemon = sPokedexView->selectedPokemon; - if ((gMain.newKeys & DPAD_UP) && r4) + if ((gMain.newKeys & DPAD_UP) && selectedPokemon) { - r2 = r4; - while (r2 != 0) + nextPokemon = selectedPokemon; + while (nextPokemon != 0) { - r2 = sub_80C0E0C(1, r2, 0, sPokedexView->pokemonListCount - 1); + nextPokemon = GetNextPosition(1, nextPokemon, 0, sPokedexView->pokemonListCount - 1); - if (sPokedexView->pokedexList[r2].seen) + if (sPokedexView->pokedexList[nextPokemon].seen) { - r4 = r2; + selectedPokemon = nextPokemon; break; } } - if (sPokedexView->selectedPokemon == r4) + if (sPokedexView->selectedPokemon == selectedPokemon) return FALSE; else { - sPokedexView->selectedPokemon = r4; - sPokedexView->unk62C -= 16; + sPokedexView->selectedPokemon = selectedPokemon; + sPokedexView->pokeBallRotation -= 16; return TRUE; } } - else if ((gMain.newKeys & DPAD_DOWN) && r4 < sPokedexView->pokemonListCount - 1) + else if ((gMain.newKeys & DPAD_DOWN) && selectedPokemon < sPokedexView->pokemonListCount - 1) { - r2 = r4; - while (r2 < sPokedexView->pokemonListCount - 1) + nextPokemon = selectedPokemon; + while (nextPokemon < sPokedexView->pokemonListCount - 1) { - r2 = sub_80C0E0C(0, r2, 0, sPokedexView->pokemonListCount - 1); + nextPokemon = GetNextPosition(0, nextPokemon, 0, sPokedexView->pokemonListCount - 1); - if (sPokedexView->pokedexList[r2].seen) + if (sPokedexView->pokedexList[nextPokemon].seen) { - r4 = r2; + selectedPokemon = nextPokemon; break; } } - if (sPokedexView->selectedPokemon == r4) + if (sPokedexView->selectedPokemon == selectedPokemon) return FALSE; else { - sPokedexView->selectedPokemon = r4; - sPokedexView->unk62C += 16; + sPokedexView->selectedPokemon = selectedPokemon; + sPokedexView->pokeBallRotation += 16; return TRUE; } } @@ -2461,7 +2721,7 @@ static u8 ClearMonSprites(void) { u16 i; - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_MONS_ON_SCREEN; i++) { if (sPokedexView->monSpriteIds[i] != 0xFFFF) { @@ -2472,7 +2732,7 @@ static u8 ClearMonSprites(void) return FALSE; } -u16 GetPokemonSpriteToDisplay(u16 species) +static u16 GetPokemonSpriteToDisplay(u16 species) { if (species >= NATIONAL_DEX_COUNT || sPokedexView->pokedexList[species].dexNum == 0xFFFF) return 0xFFFF; @@ -2482,11 +2742,11 @@ u16 GetPokemonSpriteToDisplay(u16 species) return 0; } -u32 sub_80BDACC(u16 num, s16 x, s16 y) +static u32 CreatePokedexMonSprite(u16 num, s16 x, s16 y) { u8 i; - for (i = 0; i < 4; i++) + for (i = 0; i < MAX_MONS_ON_SCREEN; i++) { if (sPokedexView->monSpriteIds[i] == 0xFFFF) { @@ -2504,223 +2764,245 @@ u32 sub_80BDACC(u16 num, s16 x, s16 y) return 0xFFFF; } -static void CreateInterfaceSprites(u8 a) +#define sIsDownArrow data[1] + +static void CreateInterfaceSprites(u8 page) { u8 spriteId; - u16 r5; -// Up arrow - spriteId = CreateSprite(&sArrowSpriteTemplate, 184, 4, 0); - gSprites[spriteId].data[1] = 0; -// Down arrow - spriteId = CreateSprite(&sArrowSpriteTemplate, 184, 156, 0); - gSprites[spriteId].data[1] = 1; + u16 digitNum; + + // Scroll arrows + spriteId = CreateSprite(&sScrollArrowSpriteTemplate, 184, 4, 0); + gSprites[spriteId].sIsDownArrow = FALSE; + spriteId = CreateSprite(&sScrollArrowSpriteTemplate, 184, 156, 0); + gSprites[spriteId].sIsDownArrow = TRUE; gSprites[spriteId].vFlip = TRUE; CreateSprite(&sScrollBarSpriteTemplate, 230, 20, 0); -// Start button + // Start button CreateSprite(&sInterfaceTextSpriteTemplate, 16, 120, 0); -// Menu text + // Menu text spriteId = CreateSprite(&sInterfaceTextSpriteTemplate, 48, 120, 0); StartSpriteAnim(&gSprites[spriteId], 3); -// Select button + // Select button spriteId = CreateSprite(&sInterfaceTextSpriteTemplate, 16, 144, 0); StartSpriteAnim(&gSprites[spriteId], 2); gSprites[spriteId].data[2] = 0x80; -// Search text + // Search text spriteId = CreateSprite(&sInterfaceTextSpriteTemplate, 48, 144, 0); StartSpriteAnim(&gSprites[spriteId], 1); - spriteId = CreateSprite(&sRotatingPokeballSpriteTemplate, 0, 80, 2); + spriteId = CreateSprite(&sRotatingPokeBallSpriteTemplate, 0, 80, 2); gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].oam.matrixNum = 30; - gSprites[spriteId].data[0] = 0x1E; + gSprites[spriteId].data[0] = 30; gSprites[spriteId].data[1] = 0; - spriteId = CreateSprite(&sRotatingPokeballSpriteTemplate, 0, 80, 2); + spriteId = CreateSprite(&sRotatingPokeBallSpriteTemplate, 0, 80, 2); gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].oam.matrixNum = 31; - gSprites[spriteId].data[0] = 0x1F; - gSprites[spriteId].data[1] = 0x80; + gSprites[spriteId].data[0] = 31; + gSprites[spriteId].data[1] = 128; - if (a == 0) + if (page == PAGE_MAIN) { - u32 _a; + bool32 drawNextDigit; if (!IsNationalPokedexEnabled()) { -// Seen text + // Seen text CreateSprite(&sSeenOwnTextSpriteTemplate, 32, 40, 1); -// Own text + // Own text spriteId = CreateSprite(&sSeenOwnTextSpriteTemplate, 32, 72, 1); StartSpriteAnim(&gSprites[spriteId], 1); - _a = 0; -// Seen value - 100s - spriteId = CreateSprite(&gUnknown_0855D224, 24, 48, 1); - r5 = sPokedexView->seenCount / 100; - StartSpriteAnim(&gSprites[spriteId], r5); - if (r5 != 0) - _a = 1; + + // Seen value - 100s + drawNextDigit = FALSE; + spriteId = CreateSprite(&sHoennDexSeenOwnNumberSpriteTemplate, 24, 48, 1); + digitNum = sPokedexView->seenCount / 100; + StartSpriteAnim(&gSprites[spriteId], digitNum); + if (digitNum != 0) + drawNextDigit = TRUE; else gSprites[spriteId].invisible = TRUE; -// Seen value - 10s - spriteId = CreateSprite(&gUnknown_0855D224, 32, 48, 1); - r5 = (sPokedexView->seenCount % 100) / 10; - if (r5 != 0 || _a != 0) - StartSpriteAnim(&gSprites[spriteId], r5); + + // Seen value - 10s + spriteId = CreateSprite(&sHoennDexSeenOwnNumberSpriteTemplate, 32, 48, 1); + digitNum = (sPokedexView->seenCount % 100) / 10; + if (digitNum != 0 || drawNextDigit) + StartSpriteAnim(&gSprites[spriteId], digitNum); else gSprites[spriteId].invisible = TRUE; -// Seen value - 1s - spriteId = CreateSprite(&gUnknown_0855D224, 40, 48, 1); - r5 = (sPokedexView->seenCount % 100) % 10; - StartSpriteAnim(&gSprites[spriteId], r5); - _a = 0; -// Owned value - 100s - spriteId = CreateSprite(&gUnknown_0855D224, 24, 80, 1); - r5 = sPokedexView->ownCount / 100; - StartSpriteAnim(&gSprites[spriteId], r5); - if (r5 != 0) - _a = 1; + + // Seen value - 1s + spriteId = CreateSprite(&sHoennDexSeenOwnNumberSpriteTemplate, 40, 48, 1); + digitNum = (sPokedexView->seenCount % 100) % 10; + StartSpriteAnim(&gSprites[spriteId], digitNum); + + // Owned value - 100s + drawNextDigit = FALSE; + spriteId = CreateSprite(&sHoennDexSeenOwnNumberSpriteTemplate, 24, 80, 1); + digitNum = sPokedexView->ownCount / 100; + StartSpriteAnim(&gSprites[spriteId], digitNum); + if (digitNum != 0) + drawNextDigit = TRUE; else gSprites[spriteId].invisible = TRUE; -// Owned value - 10s - spriteId = CreateSprite(&gUnknown_0855D224, 32, 80, 1); - r5 = (sPokedexView->ownCount % 100) / 10; - if (r5 != 0 || _a != 0) - StartSpriteAnim(&gSprites[spriteId], r5); + + // Owned value - 10s + spriteId = CreateSprite(&sHoennDexSeenOwnNumberSpriteTemplate, 32, 80, 1); + digitNum = (sPokedexView->ownCount % 100) / 10; + if (digitNum != 0 || drawNextDigit) + StartSpriteAnim(&gSprites[spriteId], digitNum); else gSprites[spriteId].invisible = TRUE; -// Owned value -1s - spriteId = CreateSprite(&gUnknown_0855D224, 40, 80, 1); - r5 = (sPokedexView->ownCount % 100) % 10; - StartSpriteAnim(&gSprites[spriteId], r5); + + // Owned value - 1s + spriteId = CreateSprite(&sHoennDexSeenOwnNumberSpriteTemplate, 40, 80, 1); + digitNum = (sPokedexView->ownCount % 100) % 10; + StartSpriteAnim(&gSprites[spriteId], digitNum); } else { - u16 r6; + u16 seenOwnedCount; + // Seen text CreateSprite(&sSeenOwnTextSpriteTemplate, 32, 40, 1); - + // Own text spriteId = CreateSprite(&sSeenOwnTextSpriteTemplate, 32, 76, 1); StartSpriteAnim(&gSprites[spriteId], 1); - CreateSprite(&gUnknown_0855D20C, 17, 45, 1); + // Hoenn text (seen) + CreateSprite(&sHoennNationalTextSpriteTemplate, 17, 45, 1); - spriteId = CreateSprite(&gUnknown_0855D20C, 17, 55, 1); + // National text (seen) + spriteId = CreateSprite(&sHoennNationalTextSpriteTemplate, 17, 55, 1); StartSpriteAnim(&gSprites[spriteId], 1); - CreateSprite(&gUnknown_0855D20C, 17, 81, 1); + // Hoenn text (own) + CreateSprite(&sHoennNationalTextSpriteTemplate, 17, 81, 1); - spriteId = CreateSprite(&gUnknown_0855D20C, 17, 91, 1); + // National text (own) + spriteId = CreateSprite(&sHoennNationalTextSpriteTemplate, 17, 91, 1); StartSpriteAnim(&gSprites[spriteId], 1); - r6 = GetHoennPokedexCount(FLAG_GET_SEEN); - _a = 0; - - spriteId = CreateSprite(&gUnknown_0855D23C, 40, 45, 1); - r5 = r6 / 100; - StartSpriteAnim(&gSprites[spriteId], r5); - if (r5 != 0) - _a = 1; + // Hoenn seen value - 100s + seenOwnedCount = GetHoennPokedexCount(FLAG_GET_SEEN); + drawNextDigit = FALSE; + spriteId = CreateSprite(&sNationalDexSeenOwnNumberSpriteTemplate, 40, 45, 1); + digitNum = seenOwnedCount / 100; + StartSpriteAnim(&gSprites[spriteId], digitNum); + if (digitNum != 0) + drawNextDigit = TRUE; else gSprites[spriteId].invisible = TRUE; - spriteId = CreateSprite(&gUnknown_0855D23C, 48, 45, 1); - r5 = (r6 % 100) / 10; - if (r5 != 0 || _a != 0) - StartSpriteAnim(&gSprites[spriteId], r5); + // Hoenn seen value - 10s + spriteId = CreateSprite(&sNationalDexSeenOwnNumberSpriteTemplate, 48, 45, 1); + digitNum = (seenOwnedCount % 100) / 10; + if (digitNum != 0 || drawNextDigit) + StartSpriteAnim(&gSprites[spriteId], digitNum); else gSprites[spriteId].invisible = TRUE; - spriteId = CreateSprite(&gUnknown_0855D23C, 56, 45, 1); - r5 = (r6 % 100) % 10; - StartSpriteAnim(&gSprites[spriteId], r5); + // Hoenn seen value - 1s + spriteId = CreateSprite(&sNationalDexSeenOwnNumberSpriteTemplate, 56, 45, 1); + digitNum = (seenOwnedCount % 100) % 10; + StartSpriteAnim(&gSprites[spriteId], digitNum); - _a = 0; - - spriteId = CreateSprite(&gUnknown_0855D23C, 40, 55, 1); - r5 = sPokedexView->seenCount / 100; - StartSpriteAnim(&gSprites[spriteId], r5); - if (r5 != 0) - _a = 1; + // National seen value - 100s + drawNextDigit = FALSE; + spriteId = CreateSprite(&sNationalDexSeenOwnNumberSpriteTemplate, 40, 55, 1); + digitNum = sPokedexView->seenCount / 100; + StartSpriteAnim(&gSprites[spriteId], digitNum); + if (digitNum != 0) + drawNextDigit = TRUE; else gSprites[spriteId].invisible = TRUE; - spriteId = CreateSprite(&gUnknown_0855D23C, 48, 55, 1); - r5 = (sPokedexView->seenCount % 100) / 10; - if (r5 != 0 || _a != 0) - StartSpriteAnim(&gSprites[spriteId], r5); + // National seen value - 10s + spriteId = CreateSprite(&sNationalDexSeenOwnNumberSpriteTemplate, 48, 55, 1); + digitNum = (sPokedexView->seenCount % 100) / 10; + if (digitNum != 0 || drawNextDigit) + StartSpriteAnim(&gSprites[spriteId], digitNum); else gSprites[spriteId].invisible = TRUE; - spriteId = CreateSprite(&gUnknown_0855D23C, 56, 55, 1); - r5 = (sPokedexView->seenCount % 100) % 10; - StartSpriteAnim(&gSprites[spriteId], r5); + // National seen value - 1s + spriteId = CreateSprite(&sNationalDexSeenOwnNumberSpriteTemplate, 56, 55, 1); + digitNum = (sPokedexView->seenCount % 100) % 10; + StartSpriteAnim(&gSprites[spriteId], digitNum); - r6 = GetHoennPokedexCount(FLAG_GET_CAUGHT); - _a = 0; + seenOwnedCount = GetHoennPokedexCount(FLAG_GET_CAUGHT); - spriteId = CreateSprite(&gUnknown_0855D23C, 40, 81, 1); - r5 = r6 / 100; - StartSpriteAnim(&gSprites[spriteId], r5); - if (r5 != 0) - _a = 1; + // Hoenn owned value - 100s + drawNextDigit = FALSE; + spriteId = CreateSprite(&sNationalDexSeenOwnNumberSpriteTemplate, 40, 81, 1); + digitNum = seenOwnedCount / 100; + StartSpriteAnim(&gSprites[spriteId], digitNum); + if (digitNum != 0) + drawNextDigit = TRUE; else gSprites[spriteId].invisible = TRUE; - spriteId = CreateSprite(&gUnknown_0855D23C, 48, 81, 1); - r5 = (r6 % 100) / 10; - if (r5 != 0 || _a != 0) - StartSpriteAnim(&gSprites[spriteId], r5); + // Hoenn owned value - 10s + spriteId = CreateSprite(&sNationalDexSeenOwnNumberSpriteTemplate, 48, 81, 1); + digitNum = (seenOwnedCount % 100) / 10; + if (digitNum != 0 || drawNextDigit) + StartSpriteAnim(&gSprites[spriteId], digitNum); else gSprites[spriteId].invisible = TRUE; - spriteId = CreateSprite(&gUnknown_0855D23C, 56, 81, 1); - r5 = (r6 % 100) % 10; - StartSpriteAnim(&gSprites[spriteId], r5); + // Hoenn owned value - 1s + spriteId = CreateSprite(&sNationalDexSeenOwnNumberSpriteTemplate, 56, 81, 1); + digitNum = (seenOwnedCount % 100) % 10; + StartSpriteAnim(&gSprites[spriteId], digitNum); - _a = 0; - - spriteId = CreateSprite(&gUnknown_0855D23C, 40, 91, 1); - r5 = sPokedexView->ownCount / 100; - StartSpriteAnim(&gSprites[spriteId], r5); - if (r5 != 0) - _a = 1; + // National owned value - 100s + drawNextDigit = FALSE; + spriteId = CreateSprite(&sNationalDexSeenOwnNumberSpriteTemplate, 40, 91, 1); + digitNum = sPokedexView->ownCount / 100; + StartSpriteAnim(&gSprites[spriteId], digitNum); + if (digitNum != 0) + drawNextDigit = TRUE; else gSprites[spriteId].invisible = TRUE; - spriteId = CreateSprite(&gUnknown_0855D23C, 48, 91, 1); - r5 = (sPokedexView->ownCount % 100) / 10; - if (r5 != 0 || _a != 0) - StartSpriteAnim(&gSprites[spriteId], r5); + // National owned value - 10s + spriteId = CreateSprite(&sNationalDexSeenOwnNumberSpriteTemplate, 48, 91, 1); + digitNum = (sPokedexView->ownCount % 100) / 10; + if (digitNum != 0 || drawNextDigit) + StartSpriteAnim(&gSprites[spriteId], digitNum); else gSprites[spriteId].invisible = TRUE; - spriteId = CreateSprite(&gUnknown_0855D23C, 56, 91, 1); - r5 = (sPokedexView->ownCount % 100) % 10; - StartSpriteAnim(&gSprites[spriteId], r5); + // National owned value - 1s + spriteId = CreateSprite(&sNationalDexSeenOwnNumberSpriteTemplate, 56, 91, 1); + digitNum = (sPokedexView->ownCount % 100) % 10; + StartSpriteAnim(&gSprites[spriteId], digitNum); } - spriteId = CreateSprite(&gUnknown_0855D254, 136, 96, 1); + spriteId = CreateSprite(&sDexListStartMenuCursorSpriteTemplate, 136, 96, 1); gSprites[spriteId].invisible = TRUE; } - else + else // PAGE_SEARCH_RESULTS { - spriteId = CreateSprite(&gUnknown_0855D254, 136, 80, 1); + spriteId = CreateSprite(&sDexListStartMenuCursorSpriteTemplate, 136, 80, 1); gSprites[spriteId].invisible = TRUE; } } -void nullsub_38(struct Sprite *sprite) +static void SpriteCB_EndMoveMonForInfoScreen(struct Sprite *sprite) { + // Once mon is done moving there's nothing left to do } -void sub_80BE44C(struct Sprite *sprite) +static void SpriteCB_SeenOwnInfo(struct Sprite *sprite) { - if (sPokedexView->unk64A != 0) + if (sPokedexView->currentPage != PAGE_MAIN) DestroySprite(sprite); } -//Move Pokemon into position for description page -void MoveMonIntoPosition(struct Sprite *sprite) +void SpriteCB_MoveMonForInfoScreen(struct Sprite *sprite) { sprite->oam.priority = 0; sprite->oam.affineMode = ST_OAM_AFFINE_OFF; @@ -2740,29 +3022,29 @@ void MoveMonIntoPosition(struct Sprite *sprite) } else { - sprite->callback = nullsub_38; + sprite->callback = SpriteCB_EndMoveMonForInfoScreen; } } -void sub_80BE4E0(struct Sprite *sprite) +static void SpriteCB_PokedexListMonSprite(struct Sprite *sprite) { - u8 data1 = sprite->data[1]; + u8 monId = sprite->data[1]; - if (sPokedexView->unk64A != 0 && sPokedexView->unk64A != 3) + if (sPokedexView->currentPage != PAGE_MAIN && sPokedexView->currentPage != PAGE_SEARCH_RESULTS) { - FreeAndDestroyMonPicSprite(sPokedexView->monSpriteIds[data1]); - sPokedexView->monSpriteIds[data1] = 0xFFFF; + FreeAndDestroyMonPicSprite(sPokedexView->monSpriteIds[monId]); + sPokedexView->monSpriteIds[monId] = 0xFFFF; } else { u32 var; sprite->pos2.y = gSineTable[(u8)sprite->data[5]] * 76 / 256; - var = 0x10000 / gSineTable[sprite->data[5] + 0x40]; + var = 0x10000 / gSineTable[sprite->data[5] + 64]; if (var > 0xFFFF) var = 0xFFFF; SetOamMatrix(sprite->data[1] + 1, 0x100, 0, 0, var); - sprite->oam.matrixNum = data1 + 1; + sprite->oam.matrixNum = monId + 1; if (sprite->data[5] > -64 && sprite->data[5] < 64) { @@ -2776,23 +3058,23 @@ void sub_80BE4E0(struct Sprite *sprite) if ((sprite->data[5] <= -64 || sprite->data[5] >= 64) && sprite->data[0] != 0) { - FreeAndDestroyMonPicSprite(sPokedexView->monSpriteIds[data1]); - sPokedexView->monSpriteIds[data1] = 0xFFFF; + FreeAndDestroyMonPicSprite(sPokedexView->monSpriteIds[monId]); + sPokedexView->monSpriteIds[monId] = 0xFFFF; } } } static void SpriteCB_Scrollbar(struct Sprite *sprite) { - if (sPokedexView->unk64A != 0 && sPokedexView->unk64A != 3) + if (sPokedexView->currentPage != PAGE_MAIN && sPokedexView->currentPage != PAGE_SEARCH_RESULTS) DestroySprite(sprite); else sprite->pos2.y = sPokedexView->selectedPokemon * 120 / (sPokedexView->pokemonListCount - 1); } -void sub_80BE658(struct Sprite *sprite) +static void SpriteCB_ScrollArrow(struct Sprite *sprite) { - if (sPokedexView->unk64A != 0 && sPokedexView->unk64A != 3) + if (sPokedexView->currentPage != PAGE_MAIN && sPokedexView->currentPage != PAGE_SEARCH_RESULTS) { DestroySprite(sprite); } @@ -2800,7 +3082,7 @@ void sub_80BE658(struct Sprite *sprite) { u8 r0; - if (sprite->data[1] != 0) + if (sprite->sIsDownArrow) { if (sPokedexView->selectedPokemon == sPokedexView->pokemonListCount - 1) sprite->invisible = TRUE; @@ -2818,22 +3100,22 @@ void sub_80BE658(struct Sprite *sprite) } sprite->pos2.y = gSineTable[r0] / 64; sprite->data[2] = sprite->data[2] + 8; - if (sPokedexView->menuIsOpen == 0 && sPokedexView->menuY == 0 && sprite->invisible == 0) + if (sPokedexView->menuIsOpen == FALSE && sPokedexView->menuY == 0 && sprite->invisible == FALSE) sprite->invisible = FALSE; else sprite->invisible = TRUE; } } -void sub_80BE758(struct Sprite *sprite) +static void SpriteCB_DexListInterfaceText(struct Sprite *sprite) { - if (sPokedexView->unk64A != 0 && sPokedexView->unk64A != 3) + if (sPokedexView->currentPage != PAGE_MAIN && sPokedexView->currentPage != PAGE_SEARCH_RESULTS) DestroySprite(sprite); } -void sub_80BE780(struct Sprite *sprite) +static void SpriteCB_RotatingPokeBall(struct Sprite *sprite) { - if (sPokedexView->unk64A != 0 && sPokedexView->unk64A != 3) + if (sPokedexView->currentPage != PAGE_MAIN && sPokedexView->currentPage != PAGE_SEARCH_RESULTS) { DestroySprite(sprite); } @@ -2843,30 +3125,30 @@ void sub_80BE780(struct Sprite *sprite) s16 r3; s16 r0; - val = sPokedexView->unk62C + sprite->data[1]; + val = sPokedexView->pokeBallRotation + sprite->data[1]; r3 = gSineTable[val]; - r0 = gSineTable[val + 0x40]; + r0 = gSineTable[val + 64]; SetOamMatrix(sprite->data[0], r0, r3, -r3, r0); - val = sPokedexView->unk62C + (sprite->data[1] + 0x40); + val = sPokedexView->pokeBallRotation + (sprite->data[1] + 64); r3 = gSineTable[val]; - r0 = gSineTable[val + 0x40]; + r0 = gSineTable[val + 64]; sprite->pos2.x = r0 * 40 / 256; sprite->pos2.y = r3 * 40 / 256; } } -void sub_80BE834(struct Sprite *sprite) +static void SpriteCB_DexListStartMenuCursor(struct Sprite *sprite) { - if (sPokedexView->unk64A != 0 && sPokedexView->unk64A != 3) + if (sPokedexView->currentPage != PAGE_MAIN && sPokedexView->currentPage != PAGE_SEARCH_RESULTS) { DestroySprite(sprite); } else { - u16 r1 = sPokedexView->unk64A == 0 ? 80 : 96; + u16 r1 = sPokedexView->currentPage == PAGE_MAIN ? 80 : 96; - if (sPokedexView->menuIsOpen != 0 && sPokedexView->menuY == r1) + if (sPokedexView->menuIsOpen && sPokedexView->menuY == r1) { sprite->invisible = FALSE; sprite->pos2.y = sPokedexView->menuCursorPos * 16; @@ -2880,24 +3162,24 @@ void sub_80BE834(struct Sprite *sprite) } } -static void PrintInfoPageText(const u8* str, u8 left, u8 top) +static void PrintInfoScreenText(const u8* str, u8 left, u8 top) { u8 color[3]; - color[0] = 0; - color[1] = 15; - color[2] = 3; + color[0] = TEXT_COLOR_TRANSPARENT; + color[1] = TEXT_DYNAMIC_COLOR_6; + color[2] = TEXT_COLOR_LIGHT_GREY; AddTextPrinterParameterized4(0, 1, left, top, 0, 0, color, -1, str); } #define tMonSpriteId data[4] -u8 SetupInfoScreen(struct PokedexListItem* item, u8 monSpriteId) +static u8 LoadInfoScreen(struct PokedexListItem* item, u8 monSpriteId) { u8 taskId; sPokedexListItem = item; - taskId = CreateTask(LoadInfoScreen, 0); + taskId = CreateTask(Task_LoadInfoScreen, 0); gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = 1; gTasks[taskId].data[2] = 0; @@ -2905,7 +3187,7 @@ u8 SetupInfoScreen(struct PokedexListItem* item, u8 monSpriteId) gTasks[taskId].tMonSpriteId = monSpriteId; gTasks[taskId].data[5] = 255; ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, sInfoScreen_BgTemplate, 4); + InitBgsFromTemplates(0, sInfoScreen_BgTemplate, ARRAY_COUNT(sInfoScreen_BgTemplate)); SetBgTilemapBuffer(3, AllocZeroed(0x800)); SetBgTilemapBuffer(2, AllocZeroed(0x800)); SetBgTilemapBuffer(1, AllocZeroed(0x800)); @@ -2916,168 +3198,170 @@ u8 SetupInfoScreen(struct PokedexListItem* item, u8 monSpriteId) return taskId; } -bool8 sub_80BE9C4(u8 taskId) +static bool8 IsInfoScreenScrolling(u8 taskId) { - if (gTasks[taskId].data[0] == 0 && gTasks[taskId].func == ChangePokedexScreen) + if (gTasks[taskId].data[0] == 0 && gTasks[taskId].func == Task_HandleInfoScreenInput) return FALSE; else return TRUE; } -u8 sub_80BE9F8(struct PokedexListItem *item, u8 b) +static u8 sub_80BE9F8(struct PokedexListItem *item, u8 taskId) { sPokedexListItem = item; - gTasks[b].data[0] = 1; - gTasks[b].data[1] = 0; - gTasks[b].data[2] = 0; - gTasks[b].data[3] = 0; - return b; + gTasks[taskId].data[0] = 1; + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[2] = 0; + gTasks[taskId].data[3] = 0; + return taskId; } -void LoadInfoScreen(u8 taskId) +static void Task_LoadInfoScreen(u8 taskId) { switch (gMain.state) { - case 0: - default: - if (!gPaletteFade.active) - { - u16 r2; + case 0: + default: + if (!gPaletteFade.active) + { + u16 r2; - sPokedexView->unk64A = 1; - gUnknown_030060B4 = gMain.vblankCallback; - SetVBlankCallback(NULL); - r2 = 0; - if (gTasks[taskId].data[1] != 0) - r2 += DISPCNT_OBJ_ON; - if (gTasks[taskId].data[2] != 0) - r2 |= DISPCNT_BG1_ON; - ResetOtherVideoRegisters(r2); - gMain.state = 1; - } - break; - case 1: - DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0); - CopyToBgTilemapBuffer(3, gPokedexTilemap_DescriptionScreen, 0, 0); - FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0)); - PutWindowTilemap(WIN_INFO); - PutWindowTilemap(WIN_FOOTPRINT); - PrintFootprint(WIN_FOOTPRINT, sPokedexListItem->dexNum); - CopyWindowToVram(WIN_FOOTPRINT, 2); - gMain.state++; - break; - case 2: - sub_80BFCDC(0xD); - sub_80BFD0C(sPokedexView->selectedScreen, 0xD); - LoadPokedexBgPalette(sPokedexView->unk64C_1); - gMain.state++; - break; - case 3: - gMain.state++; - break; - case 4: - PrintMonInfo(sPokedexListItem->dexNum, sPokedexView->dexMode == 0 ? 0 : 1, sPokedexListItem->owned, 0); - if (!sPokedexListItem->owned) - LoadPalette(gPlttBufferUnfaded + 1, 0x31, 0x1E); - CopyWindowToVram(WIN_INFO, 3); - CopyBgTilemapBufferToVram(1); - CopyBgTilemapBufferToVram(2); - CopyBgTilemapBufferToVram(3); - gMain.state++; - break; - case 5: - if (gTasks[taskId].data[1] == 0) - { - gTasks[taskId].tMonSpriteId = (u16)CreateMonSpriteFromNationalDexNumber(sPokedexListItem->dexNum, 48, 56, 0); - gSprites[gTasks[taskId].tMonSpriteId].oam.priority = 0; - } - gMain.state++; - break; - case 6: - { - u32 preservedPalettes = 0; + sPokedexView->currentPage = PAGE_INFO; + gPokedexVBlankCB = gMain.vblankCallback; + SetVBlankCallback(NULL); + r2 = 0; + if (gTasks[taskId].data[1] != 0) + r2 += DISPCNT_OBJ_ON; + if (gTasks[taskId].data[2] != 0) + r2 |= DISPCNT_BG1_ON; + ResetOtherVideoRegisters(r2); + gMain.state = 1; + } + break; + case 1: + DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0); + CopyToBgTilemapBuffer(3, gPokedexInfoScreen_Tilemap, 0, 0); + FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0)); + PutWindowTilemap(WIN_INFO); + PutWindowTilemap(WIN_FOOTPRINT); + PrintFootprint(WIN_FOOTPRINT, sPokedexListItem->dexNum); + CopyWindowToVram(WIN_FOOTPRINT, 2); + gMain.state++; + break; + case 2: + LoadScreenSelectBarMain(0xD); + HighlightScreenSelectBarItem(sPokedexView->selectedScreen, 0xD); + LoadPokedexBgPalette(sPokedexView->isSearchResults); + gMain.state++; + break; + case 3: + gMain.state++; + break; + case 4: + PrintMonInfo(sPokedexListItem->dexNum, sPokedexView->dexMode == DEX_MODE_HOENN ? FALSE : TRUE, sPokedexListItem->owned, 0); + if (!sPokedexListItem->owned) + LoadPalette(gPlttBufferUnfaded + 1, 0x31, 0x1E); + CopyWindowToVram(WIN_INFO, 3); + CopyBgTilemapBufferToVram(1); + CopyBgTilemapBufferToVram(2); + CopyBgTilemapBufferToVram(3); + gMain.state++; + break; + case 5: + if (gTasks[taskId].data[1] == 0) + { + gTasks[taskId].tMonSpriteId = (u16)CreateMonSpriteFromNationalDexNumber(sPokedexListItem->dexNum, 48, 56, 0); + gSprites[gTasks[taskId].tMonSpriteId].oam.priority = 0; + } + gMain.state++; + break; + case 6: + { + u32 preservedPalettes = 0; - if (gTasks[taskId].data[2] != 0) - preservedPalettes = 0x14; // each bit represents a palette index - if (gTasks[taskId].data[1] != 0) - preservedPalettes |= (1 << (gSprites[gTasks[taskId].tMonSpriteId].oam.paletteNum + 16)); - BeginNormalPaletteFade(~preservedPalettes, 0, 16, 0, RGB_BLACK); - SetVBlankCallback(gUnknown_030060B4); - gMain.state++; - } - break; - case 7: - SetGpuReg(REG_OFFSET_BLDCNT, 0); - SetGpuReg(REG_OFFSET_BLDALPHA, 0); - SetGpuReg(REG_OFFSET_BLDY, 0); - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); - HideBg(0); - ShowBg(1); - ShowBg(2); - ShowBg(3); + if (gTasks[taskId].data[2] != 0) + preservedPalettes = 0x14; // each bit represents a palette index + if (gTasks[taskId].data[1] != 0) + preservedPalettes |= (1 << (gSprites[gTasks[taskId].tMonSpriteId].oam.paletteNum + 16)); + BeginNormalPaletteFade(~preservedPalettes, 0, 16, 0, RGB_BLACK); + SetVBlankCallback(gPokedexVBlankCB); gMain.state++; - break; - case 8: - if (!gPaletteFade.active) + } + break; + case 7: + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); + HideBg(0); + ShowBg(1); + ShowBg(2); + ShowBg(3); + gMain.state++; + break; + case 8: + if (!gPaletteFade.active) + { + gMain.state++; + if (gTasks[taskId].data[3] == 0) + { + StopCryAndClearCrySongs(); + PlayCry2(NationalPokedexNumToSpecies(sPokedexListItem->dexNum), 0, 0x7D, 0xA); + } + else { gMain.state++; - if (gTasks[taskId].data[3] == 0) - { - StopCryAndClearCrySongs(); - PlayCry2(NationalPokedexNumToSpecies(sPokedexListItem->dexNum), 0, 0x7D, 0xA); - } - else - { - gMain.state++; - } } - break; - case 9: - if (!IsCryPlayingOrClearCrySongs()) - gMain.state++; - break; - case 10: - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[1] = 0; - gTasks[taskId].data[2] = 1; - gTasks[taskId].data[3] = 1; - gTasks[taskId].func = ChangePokedexScreen; - gMain.state = 0; - break; + } + break; + case 9: + if (!IsCryPlayingOrClearCrySongs()) + gMain.state++; + break; + case 10: + gTasks[taskId].data[0] = 0; + gTasks[taskId].data[1] = 0; + gTasks[taskId].data[2] = 1; + gTasks[taskId].data[3] = 1; + gTasks[taskId].func = Task_HandleInfoScreenInput; + gMain.state = 0; + break; } } -static void FreeWindowAndBgBuffers_(void) +static void FreeInfoScreenWindowAndBgBuffers(void) { - void *r0; + void *tilemapBuffer; + FreeAllWindowBuffers(); - r0 = GetBgTilemapBuffer(0); - if (r0) - Free(r0); - r0 = GetBgTilemapBuffer(1); - if (r0) - Free(r0); - r0 = GetBgTilemapBuffer(2); - if (r0) - Free(r0); - r0 = GetBgTilemapBuffer(3); - if (r0) - Free(r0); + tilemapBuffer = GetBgTilemapBuffer(0); + if (tilemapBuffer) + Free(tilemapBuffer); + tilemapBuffer = GetBgTilemapBuffer(1); + if (tilemapBuffer) + Free(tilemapBuffer); + tilemapBuffer = GetBgTilemapBuffer(2); + if (tilemapBuffer) + Free(tilemapBuffer); + tilemapBuffer = GetBgTilemapBuffer(3); + if (tilemapBuffer) + Free(tilemapBuffer); } -void ChangePokedexScreen(u8 taskId) +static void Task_HandleInfoScreenInput(u8 taskId) { if (gTasks[taskId].data[0] != 0) { + // Scroll up/down BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gTasks[taskId].func = BeginChangeInfoScreen; + gTasks[taskId].func = Task_LoadInfoScreenWaitForFade; PlaySE(SE_Z_SCROLL); return; } if (gMain.newKeys & B_BUTTON) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gTasks[taskId].func = BeginReturnToPokedex; + gTasks[taskId].func = Task_ExitInfoScreen; PlaySE(SE_PC_OFF); return; } @@ -3085,36 +3369,36 @@ void ChangePokedexScreen(u8 taskId) { switch (sPokedexView->selectedScreen) { - case AREA_SCREEN: - BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 16, RGB_BLACK); - sPokedexView->unk64E = 1; - gTasks[taskId].func = LoadSelectedScreen; - PlaySE(SE_PIN); - break; - case CRY_SCREEN: + case AREA_SCREEN: + BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 16, RGB_BLACK); + sPokedexView->screenSwitchState = 1; + gTasks[taskId].func = Task_SwitchScreensFromInfoScreen; + PlaySE(SE_PIN); + break; + case CRY_SCREEN: + BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK); + sPokedexView->screenSwitchState = 2; + gTasks[taskId].func = Task_SwitchScreensFromInfoScreen; + PlaySE(SE_PIN); + break; + case SIZE_SCREEN: + if (!sPokedexListItem->owned) + { + PlaySE(SE_HAZURE); + } + else + { BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK); - sPokedexView->unk64E = 2; - gTasks[taskId].func = LoadSelectedScreen; + sPokedexView->screenSwitchState = 3; + gTasks[taskId].func = Task_SwitchScreensFromInfoScreen; PlaySE(SE_PIN); - break; - case SIZE_SCREEN: - if (!sPokedexListItem->owned) - { - PlaySE(SE_HAZURE); - } - else - { - BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK); - sPokedexView->unk64E = 3; - gTasks[taskId].func = LoadSelectedScreen; - PlaySE(SE_PIN); - } - break; - case CANCEL_SCREEN: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); - gTasks[taskId].func = BeginReturnToPokedex; - PlaySE(SE_PC_OFF); - break; + } + break; + case CANCEL_SCREEN: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); + gTasks[taskId].func = Task_ExitInfoScreen; + PlaySE(SE_PC_OFF); + break; } return; } @@ -3123,235 +3407,235 @@ void ChangePokedexScreen(u8 taskId) && sPokedexView->selectedScreen > 0) { sPokedexView->selectedScreen--; - sub_80BFD0C(sPokedexView->selectedScreen, 0xD); + HighlightScreenSelectBarItem(sPokedexView->selectedScreen, 0xD); PlaySE(SE_Z_PAGE); return; } if (((gMain.newKeys & DPAD_RIGHT) || ((gMain.newKeys & R_BUTTON) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) - && sPokedexView->selectedScreen < 3) + && sPokedexView->selectedScreen < CANCEL_SCREEN) { sPokedexView->selectedScreen++; - sub_80BFD0C(sPokedexView->selectedScreen, 0xD); + HighlightScreenSelectBarItem(sPokedexView->selectedScreen, 0xD); PlaySE(SE_Z_PAGE); return; } } -void LoadSelectedScreen(u8 taskId) +static void Task_SwitchScreensFromInfoScreen(u8 taskId) { if (!gPaletteFade.active) { FreeAndDestroyMonPicSprite(gTasks[taskId].tMonSpriteId); - switch (sPokedexView->unk64E) + switch (sPokedexView->screenSwitchState) { - case 1: - default: - gTasks[taskId].func = LoadAreaScreen; - break; - case 2: - gTasks[taskId].func = LoadCryScreen; - break; - case 3: - gTasks[taskId].func = LoadSizeScreen; - break; + case 1: + default: + gTasks[taskId].func = Task_LoadAreaScreen; + break; + case 2: + gTasks[taskId].func = Task_LoadCryScreen; + break; + case 3: + gTasks[taskId].func = Task_LoadSizeScreen; + break; } } } -void BeginChangeInfoScreen(u8 taskId) +static void Task_LoadInfoScreenWaitForFade(u8 taskId) { if (!gPaletteFade.active) { FreeAndDestroyMonPicSprite(gTasks[taskId].tMonSpriteId); - gTasks[taskId].func = LoadInfoScreen; + gTasks[taskId].func = Task_LoadInfoScreen; } } -void BeginReturnToPokedex(u8 taskId) +static void Task_ExitInfoScreen(u8 taskId) { if (!gPaletteFade.active) { FreeAndDestroyMonPicSprite(gTasks[taskId].tMonSpriteId); - FreeWindowAndBgBuffers_(); + FreeInfoScreenWindowAndBgBuffers(); DestroyTask(taskId); } } -void LoadAreaScreen(u8 taskId) +static void Task_LoadAreaScreen(u8 taskId) { switch (gMain.state) { - case 0: - default: - if (!gPaletteFade.active) - { - sPokedexView->unk64A = 5; - gUnknown_030060B4 = gMain.vblankCallback; - SetVBlankCallback(NULL); - ResetOtherVideoRegisters(DISPCNT_BG1_ON); - sPokedexView->selectedScreen = AREA_SCREEN; - gMain.state = 1; - } - break; - case 1: - sub_80BFCF4(0xD); - sub_80BFD7C(0, 0xD); - LoadPokedexBgPalette(sPokedexView->unk64C_1); - SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(13) | BGCNT_16COLOR | BGCNT_TXT256x256); - gMain.state++; - break; - case 2: - ShowPokedexAreaScreen(NationalPokedexNumToSpecies(sPokedexListItem->dexNum), &sPokedexView->unk64E); - SetVBlankCallback(gUnknown_030060B4); - sPokedexView->unk64E = 0; - gMain.state = 0; - gTasks[taskId].func = WaitForAreaScreenInput; - break; + case 0: + default: + if (!gPaletteFade.active) + { + sPokedexView->currentPage = PAGE_AREA; + gPokedexVBlankCB = gMain.vblankCallback; + SetVBlankCallback(NULL); + ResetOtherVideoRegisters(DISPCNT_BG1_ON); + sPokedexView->selectedScreen = AREA_SCREEN; + gMain.state = 1; + } + break; + case 1: + LoadScreenSelectBarSubmenu(0xD); + HighlightSubmenuScreenSelectBarItem(0, 0xD); + LoadPokedexBgPalette(sPokedexView->isSearchResults); + SetGpuReg(REG_OFFSET_BG1CNT, BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(13) | BGCNT_16COLOR | BGCNT_TXT256x256); + gMain.state++; + break; + case 2: + ShowPokedexAreaScreen(NationalPokedexNumToSpecies(sPokedexListItem->dexNum), &sPokedexView->screenSwitchState); + SetVBlankCallback(gPokedexVBlankCB); + sPokedexView->screenSwitchState = 0; + gMain.state = 0; + gTasks[taskId].func = Task_WaitForAreaScreenInput; + break; } } -static void WaitForAreaScreenInput(u8 taskId) +static void Task_WaitForAreaScreenInput(u8 taskId) { -// See Task_PokedexAreaScreen_1() in pokedex_area_screen.c - if (sPokedexView->unk64E != 0) - gTasks[taskId].func = sub_80BF1EC; +// See Task_HandlePokedexAreaScreenInput() in pokedex_area_screen.c + if (sPokedexView->screenSwitchState != 0) + gTasks[taskId].func = Task_SwitchScreensFromAreaScreen; } -void sub_80BF1EC(u8 taskId) +static void Task_SwitchScreensFromAreaScreen(u8 taskId) { if (!gPaletteFade.active) { - switch (sPokedexView->unk64E) + switch (sPokedexView->screenSwitchState) { - case 1: - default: - gTasks[taskId].func = LoadInfoScreen; - break; - case 2: - gTasks[taskId].func = LoadCryScreen; - break; + case 1: + default: + gTasks[taskId].func = Task_LoadInfoScreen; + break; + case 2: + gTasks[taskId].func = Task_LoadCryScreen; + break; } } } -void LoadCryScreen(u8 taskId) +static void Task_LoadCryScreen(u8 taskId) { switch (gMain.state) { - case 0: - default: - if (!gPaletteFade.active) - { - m4aMPlayStop(&gMPlayInfo_BGM); - sPokedexView->unk64A = 6; - gUnknown_030060B4 = gMain.vblankCallback; - SetVBlankCallback(NULL); - ResetOtherVideoRegisters(DISPCNT_BG1_ON); - sPokedexView->selectedScreen = CRY_SCREEN; - gMain.state = 1; - } - break; - case 1: - DecompressAndLoadBgGfxUsingHeap(3, &gPokedexMenu_Gfx, 0x2000, 0, 0); - CopyToBgTilemapBuffer(3, &gPokedexTilemap_CryScreen, 0, 0); - FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0)); - PutWindowTilemap(WIN_INFO); - PutWindowTilemap(WIN_VU_METER); - PutWindowTilemap(WIN_CRY_WAVE); - gMain.state++; - break; - case 2: - sub_80BFCF4(0xD); - sub_80BFD7C(1, 0xD); - LoadPokedexBgPalette(sPokedexView->unk64C_1); - gMain.state++; - break; - case 3: - ResetPaletteFade(); - gMain.state++; - break; - case 4: - PrintInfoPageText(gText_CryOf, 0x52, 33); - sub_80C0B44(0, sPokedexListItem->dexNum, 0x52, 49); - gMain.state++; - break; - case 5: - gTasks[taskId].tMonSpriteId = CreateMonSpriteFromNationalDexNumber(sPokedexListItem->dexNum, 48, 56, 0); - gSprites[gTasks[taskId].tMonSpriteId].oam.priority = 0; - gDexCryScreenState = 0; - gMain.state++; - break; - case 6: - { - struct CryRelatedStruct sp4; + case 0: + default: + if (!gPaletteFade.active) + { + m4aMPlayStop(&gMPlayInfo_BGM); + sPokedexView->currentPage = PAGE_CRY; + gPokedexVBlankCB = gMain.vblankCallback; + SetVBlankCallback(NULL); + ResetOtherVideoRegisters(DISPCNT_BG1_ON); + sPokedexView->selectedScreen = CRY_SCREEN; + gMain.state = 1; + } + break; + case 1: + DecompressAndLoadBgGfxUsingHeap(3, &gPokedexMenu_Gfx, 0x2000, 0, 0); + CopyToBgTilemapBuffer(3, &gPokedexCryScreen_Tilemap, 0, 0); + FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0)); + PutWindowTilemap(WIN_INFO); + PutWindowTilemap(WIN_VU_METER); + PutWindowTilemap(WIN_CRY_WAVE); + gMain.state++; + break; + case 2: + LoadScreenSelectBarSubmenu(0xD); + HighlightSubmenuScreenSelectBarItem(1, 0xD); + LoadPokedexBgPalette(sPokedexView->isSearchResults); + gMain.state++; + break; + case 3: + ResetPaletteFade(); + gMain.state++; + break; + case 4: + PrintInfoScreenText(gText_CryOf, 82, 33); + PrintCryScreenSpeciesName(0, sPokedexListItem->dexNum, 82, 49); + gMain.state++; + break; + case 5: + gTasks[taskId].tMonSpriteId = CreateMonSpriteFromNationalDexNumber(sPokedexListItem->dexNum, 48, 56, 0); + gSprites[gTasks[taskId].tMonSpriteId].oam.priority = 0; + gDexCryScreenState = 0; + gMain.state++; + break; + case 6: + { + struct CryScreenWindow waveformWindow; - sp4.unk0 = 0x4020; - sp4.unk2 = 0x1F; - sp4.paletteNo = 8; - sp4.yPos = 0x1E; - sp4.xPos = 0xC; - if (sub_8145354(&sp4, 2) != 0) - { - gMain.state++; - gDexCryScreenState = 0; - } - } - break; - case 7: + waveformWindow.unk0 = 0x4020; + waveformWindow.unk2 = 31; + waveformWindow.paletteNo = 8; + waveformWindow.yPos = 30; + waveformWindow.xPos = 12; + if (LoadCryWaveformWindow(&waveformWindow, 2)) { - struct CryRelatedStruct spC; - - spC.paletteNo = 9; - spC.xPos = 0x12; - spC.yPos = 3; - if (sub_8145850(&spC, 3) != 0) - gMain.state++; - CopyWindowToVram(WIN_VU_METER, 2); - CopyWindowToVram(WIN_INFO, 3); - CopyBgTilemapBufferToVram(0); - CopyBgTilemapBufferToVram(1); - CopyBgTilemapBufferToVram(2); - CopyBgTilemapBufferToVram(3); + gMain.state++; + gDexCryScreenState = 0; } - break; - case 8: - BeginNormalPaletteFade(0xFFFFFFEB, 0, 0x10, 0, RGB_BLACK); - SetVBlankCallback(gUnknown_030060B4); - gMain.state++; - break; - case 9: - SetGpuReg(REG_OFFSET_BLDCNT, 0); - SetGpuReg(REG_OFFSET_BLDALPHA, 0); - SetGpuReg(REG_OFFSET_BLDY, 0); - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); - ShowBg(0); - ShowBg(1); - ShowBg(2); - ShowBg(3); - gMain.state++; - break; - case 10: - sPokedexView->unk64E = 0; - gMain.state = 0; - gTasks[taskId].func = sub_80BF5CC; - break; + } + break; + case 7: + { + struct CryScreenWindow cryMeter; + + cryMeter.paletteNo = 9; + cryMeter.xPos = 18; + cryMeter.yPos = 3; + if (LoadCryMeter(&cryMeter, 3)) + gMain.state++; + CopyWindowToVram(WIN_VU_METER, 2); + CopyWindowToVram(WIN_INFO, 3); + CopyBgTilemapBufferToVram(0); + CopyBgTilemapBufferToVram(1); + CopyBgTilemapBufferToVram(2); + CopyBgTilemapBufferToVram(3); + } + break; + case 8: + BeginNormalPaletteFade(0xFFFFFFEB, 0, 0x10, 0, RGB_BLACK); + SetVBlankCallback(gPokedexVBlankCB); + gMain.state++; + break; + case 9: + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); + ShowBg(0); + ShowBg(1); + ShowBg(2); + ShowBg(3); + gMain.state++; + break; + case 10: + sPokedexView->screenSwitchState = 0; + gMain.state = 0; + gTasks[taskId].func = Task_HandleCryScreenInput; + break; } } -void sub_80BF5CC(u8 taskId) +static void Task_HandleCryScreenInput(u8 taskId) { - sub_814545C(2); + UpdateCryWaveformWindow(2); if (IsCryPlaying()) - sub_80BF7FC(1); + LoadPlayArrowPalette(TRUE); else - sub_80BF7FC(0); + LoadPlayArrowPalette(FALSE); if (gMain.newKeys & A_BUTTON) { - sub_80BF7FC(1); - sub_8145534(NationalPokedexNumToSpecies(sPokedexListItem->dexNum)); + LoadPlayArrowPalette(TRUE); + CryScreenPlayButton(NationalPokedexNumToSpecies(sPokedexListItem->dexNum)); return; } else if (!gPaletteFade.active) @@ -3360,8 +3644,8 @@ void sub_80BF5CC(u8 taskId) { BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK); m4aMPlayContinue(&gMPlayInfo_BGM); - sPokedexView->unk64E = 1; - gTasks[taskId].func = sub_80BF790; + sPokedexView->screenSwitchState = 1; + gTasks[taskId].func = Task_SwitchScreensFromCryScreen; PlaySE(SE_PC_OFF); return; } @@ -3370,8 +3654,8 @@ void sub_80BF5CC(u8 taskId) { BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK); m4aMPlayContinue(&gMPlayInfo_BGM); - sPokedexView->unk64E = 2; - gTasks[taskId].func = sub_80BF790; + sPokedexView->screenSwitchState = 2; + gTasks[taskId].func = Task_SwitchScreensFromCryScreen; PlaySE(SE_Z_PAGE); return; } @@ -3386,8 +3670,8 @@ void sub_80BF5CC(u8 taskId) { BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK); m4aMPlayContinue(&gMPlayInfo_BGM); - sPokedexView->unk64E = 3; - gTasks[taskId].func = sub_80BF790; + sPokedexView->screenSwitchState = 3; + gTasks[taskId].func = Task_SwitchScreensFromCryScreen; PlaySE(SE_Z_PAGE); } return; @@ -3395,200 +3679,204 @@ void sub_80BF5CC(u8 taskId) } } -void sub_80BF790(u8 taskId) +static void Task_SwitchScreensFromCryScreen(u8 taskId) { if (!gPaletteFade.active) { - sub_8145914(); + FreeCryScreen(); FreeAndDestroyMonPicSprite(gTasks[taskId].tMonSpriteId); - switch (sPokedexView->unk64E) + switch (sPokedexView->screenSwitchState) { - default: - case 1: - gTasks[taskId].func = LoadInfoScreen; - break; - case 2: - gTasks[taskId].func = LoadAreaScreen; - break; - case 3: - gTasks[taskId].func = LoadSizeScreen; - break; + default: + case 1: + gTasks[taskId].func = Task_LoadInfoScreen; + break; + case 2: + gTasks[taskId].func = Task_LoadAreaScreen; + break; + case 3: + gTasks[taskId].func = Task_LoadSizeScreen; + break; } } } -void sub_80BF7FC(u8 a) +static void LoadPlayArrowPalette(bool8 cryPlaying) { - u16 unk; + u16 color; - if (a != 0) - unk = RGB(18, 28, 0); + if (cryPlaying) + color = RGB(18, 28, 0); else - unk = RGB(15, 21, 0); - LoadPalette(&unk, 0x5D, 2); + color = RGB(15, 21, 0); + LoadPalette(&color, 0x5D, 2); } -void LoadSizeScreen(u8 taskId) +static void Task_LoadSizeScreen(u8 taskId) { u8 spriteId; switch (gMain.state) { - default: - case 0: - if (!gPaletteFade.active) - { - sPokedexView->unk64A = 7; - gUnknown_030060B4 = gMain.vblankCallback; - SetVBlankCallback(NULL); - ResetOtherVideoRegisters(DISPCNT_BG1_ON); - sPokedexView->selectedScreen = SIZE_SCREEN; - gMain.state = 1; - } - break; - case 1: - DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0); - CopyToBgTilemapBuffer(3, gPokedexTilemap_SizeScreen, 0, 0); - FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0)); - PutWindowTilemap(WIN_INFO); - gMain.state++; - break; - case 2: - sub_80BFCF4(0xD); - sub_80BFD7C(2, 0xD); - LoadPokedexBgPalette(sPokedexView->unk64C_1); - gMain.state++; - break; - case 3: - { - u8 string[0x40]; //I hope this is the correct size + default: + case 0: + if (!gPaletteFade.active) + { + sPokedexView->currentPage = PAGE_SIZE; + gPokedexVBlankCB = gMain.vblankCallback; + SetVBlankCallback(NULL); + ResetOtherVideoRegisters(DISPCNT_BG1_ON); + sPokedexView->selectedScreen = SIZE_SCREEN; + gMain.state = 1; + } + break; + case 1: + DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0); + CopyToBgTilemapBuffer(3, gPokedexSizeScreen_Tilemap, 0, 0); + FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0)); + PutWindowTilemap(WIN_INFO); + gMain.state++; + break; + case 2: + LoadScreenSelectBarSubmenu(0xD); + HighlightSubmenuScreenSelectBarItem(2, 0xD); + LoadPokedexBgPalette(sPokedexView->isSearchResults); + gMain.state++; + break; + case 3: + { + u8 string[64]; - StringCopy(string, gText_SizeComparedTo); - StringAppend(string, gSaveBlock2Ptr->playerName); - PrintInfoPageText(string, GetStringCenterAlignXOffset(1, string, 0xF0), 0x79); - gMain.state++; - } - break; - case 4: - ResetPaletteFade(); + StringCopy(string, gText_SizeComparedTo); + StringAppend(string, gSaveBlock2Ptr->playerName); + PrintInfoScreenText(string, GetStringCenterAlignXOffset(1, string, 0xF0), 0x79); gMain.state++; - break; - case 5: - spriteId = sub_80C0EF8(PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender), 152, 56, 0); - gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; - gSprites[spriteId].oam.matrixNum = 1; - gSprites[spriteId].oam.priority = 0; - gSprites[spriteId].pos2.y = gPokedexEntries[sPokedexListItem->dexNum].trainerOffset; - SetOamMatrix(1, gPokedexEntries[sPokedexListItem->dexNum].trainerScale, 0, 0, gPokedexEntries[sPokedexListItem->dexNum].trainerScale); - LoadPalette(gUnknown_0856E610, (gSprites[spriteId].oam.paletteNum + 16) * 16, 0x20); - gTasks[taskId].data[5] = spriteId; - gMain.state++; - break; - case 6: - spriteId = CreateMonSpriteFromNationalDexNumber(sPokedexListItem->dexNum, 88, 56, 1); - gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; - gSprites[spriteId].oam.matrixNum = 2; - gSprites[spriteId].oam.priority = 0; - gSprites[spriteId].pos2.y = gPokedexEntries[sPokedexListItem->dexNum].pokemonOffset; - SetOamMatrix(2, gPokedexEntries[sPokedexListItem->dexNum].pokemonScale, 0, 0, gPokedexEntries[sPokedexListItem->dexNum].pokemonScale); - LoadPalette(gUnknown_0856E610, (gSprites[spriteId].oam.paletteNum + 16) * 16, 0x20); - gTasks[taskId].tMonSpriteId = spriteId; - CopyWindowToVram(WIN_INFO, 3); - CopyBgTilemapBufferToVram(1); - CopyBgTilemapBufferToVram(2); - CopyBgTilemapBufferToVram(3); - gMain.state++; - break; - case 7: - BeginNormalPaletteFade(0xFFFFFFEB, 0, 0x10, 0, RGB_BLACK); - SetVBlankCallback(gUnknown_030060B4); - gMain.state++; - break; - case 8: - SetGpuReg(REG_OFFSET_BLDCNT, 0); - SetGpuReg(REG_OFFSET_BLDALPHA, 0); - SetGpuReg(REG_OFFSET_BLDY, 0); - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); - HideBg(0); - ShowBg(1); - ShowBg(2); - ShowBg(3); - gMain.state++; - break; - case 9: - if (!gPaletteFade.active) - { - sPokedexView->unk64E = 0; - gMain.state = 0; - gTasks[taskId].func = sub_80BFBB0; - } - break; + } + break; + case 4: + ResetPaletteFade(); + gMain.state++; + break; + case 5: + spriteId = CreateSizeScreenTrainerPic(PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender), 152, 56, 0); + gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; + gSprites[spriteId].oam.matrixNum = 1; + gSprites[spriteId].oam.priority = 0; + gSprites[spriteId].pos2.y = gPokedexEntries[sPokedexListItem->dexNum].trainerOffset; + SetOamMatrix(1, gPokedexEntries[sPokedexListItem->dexNum].trainerScale, 0, 0, gPokedexEntries[sPokedexListItem->dexNum].trainerScale); + LoadPalette(sSizeScreenSilhouette_Pal, (gSprites[spriteId].oam.paletteNum + 16) * 16, 0x20); + gTasks[taskId].data[5] = spriteId; + gMain.state++; + break; + case 6: + spriteId = CreateMonSpriteFromNationalDexNumber(sPokedexListItem->dexNum, 88, 56, 1); + gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; + gSprites[spriteId].oam.matrixNum = 2; + gSprites[spriteId].oam.priority = 0; + gSprites[spriteId].pos2.y = gPokedexEntries[sPokedexListItem->dexNum].pokemonOffset; + SetOamMatrix(2, gPokedexEntries[sPokedexListItem->dexNum].pokemonScale, 0, 0, gPokedexEntries[sPokedexListItem->dexNum].pokemonScale); + LoadPalette(sSizeScreenSilhouette_Pal, (gSprites[spriteId].oam.paletteNum + 16) * 16, 0x20); + gTasks[taskId].tMonSpriteId = spriteId; + CopyWindowToVram(WIN_INFO, 3); + CopyBgTilemapBufferToVram(1); + CopyBgTilemapBufferToVram(2); + CopyBgTilemapBufferToVram(3); + gMain.state++; + break; + case 7: + BeginNormalPaletteFade(0xFFFFFFEB, 0, 0x10, 0, RGB_BLACK); + SetVBlankCallback(gPokedexVBlankCB); + gMain.state++; + break; + case 8: + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); + HideBg(0); + ShowBg(1); + ShowBg(2); + ShowBg(3); + gMain.state++; + break; + case 9: + if (!gPaletteFade.active) + { + sPokedexView->screenSwitchState = 0; + gMain.state = 0; + gTasks[taskId].func = Task_HandleSizeScreenInput; + } + break; } } -void sub_80BFBB0(u8 taskId) +static void Task_HandleSizeScreenInput(u8 taskId) { if (gMain.newKeys & B_BUTTON) { BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK); - sPokedexView->unk64E = 1; - gTasks[taskId].func = sub_80BFC78; + sPokedexView->screenSwitchState = 1; + gTasks[taskId].func = Task_SwitchScreensFromSizeScreen; PlaySE(SE_PC_OFF); } else if ((gMain.newKeys & DPAD_LEFT) || ((gMain.newKeys & L_BUTTON) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) { BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK); - sPokedexView->unk64E = 2; - gTasks[taskId].func = sub_80BFC78; + sPokedexView->screenSwitchState = 2; + gTasks[taskId].func = Task_SwitchScreensFromSizeScreen; PlaySE(SE_Z_PAGE); } } -void sub_80BFC78(u8 taskId) +static void Task_SwitchScreensFromSizeScreen(u8 taskId) { if (!gPaletteFade.active) { FreeAndDestroyMonPicSprite(gTasks[taskId].tMonSpriteId); FreeAndDestroyTrainerPicSprite(gTasks[taskId].data[5]); - switch (sPokedexView->unk64E) + switch (sPokedexView->screenSwitchState) { - default: - case 1: - gTasks[taskId].func = LoadInfoScreen; - break; - case 2: - gTasks[taskId].func = LoadCryScreen; - break; + default: + case 1: + gTasks[taskId].func = Task_LoadInfoScreen; + break; + case 2: + gTasks[taskId].func = Task_LoadCryScreen; + break; } } } -void sub_80BFCDC(u16 a) +#undef tMonSpriteId + +static void LoadScreenSelectBarMain(u16 unused) { - CopyToBgTilemapBuffer(1, gPokedexTilemap_ScreenSelectBar1, 0, 0); + CopyToBgTilemapBuffer(1, gPokedexScreenSelectBarMain_Tilemap, 0, 0); } -void sub_80BFCF4(u16 a) +static void LoadScreenSelectBarSubmenu(u16 unused) { - CopyToBgTilemapBuffer(1, gPokedexTilemap_ScreenSelectBar2, 0, 0); + CopyToBgTilemapBuffer(1, gPokedexScreenSelectBarSubmenu_Tilemap, 0, 0); } -#ifdef NONMATCHING -// This doesn't match because gcc flips the naming of the r3 and r4 -// registers. -void sub_80BFD0C(u8 a, u16 unused) + +static void HighlightScreenSelectBarItem(u8 selectedScreen, u16 unused) { u8 i; u8 j; u16* ptr = GetBgTilemapBuffer(1); - for (i = 0; i < 4; i++) + for (i = 0; i < SCREEN_COUNT; i++) { u8 row = (i * 7) + 1; - u16 newPalette = 0x4000; + u16 newPalette; - if (i == a) - newPalette = 0x2000; + do + { + newPalette = 0x4000; + if (i == selectedScreen) + newPalette = 0x2000; + } while (0); for (j = 0; j < 7; j++) { @@ -3598,75 +3886,8 @@ void sub_80BFD0C(u8 a, u16 unused) } CopyBgTilemapBufferToVram(1); } -#else -__attribute__((naked)) -void sub_80BFD0C(u8 a, u16 unused) -{ - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r8\n\ - push {r7}\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - mov r8, r0\n\ - movs r0, 0x1\n\ - bl GetBgTilemapBuffer\n\ - adds r7, r0, 0\n\ - movs r1, 0\n\ -_080BFD22:\n\ - lsls r0, r1, 3\n\ - subs r0, r1\n\ - adds r0, 0x1\n\ - lsls r0, 24\n\ - lsrs r5, r0, 24\n\ - movs r3, 0x80\n\ - lsls r3, 7\n\ - cmp r1, r8\n\ - bne _080BFD38\n\ - movs r3, 0x80\n\ - lsls r3, 6\n\ -_080BFD38:\n\ - movs r2, 0\n\ - adds r6, r1, 0x1\n\ - ldr r4, =0x00000fff\n\ -_080BFD3E:\n\ - adds r1, r5, r2\n\ - lsls r1, 1\n\ - adds r1, r7\n\ - ldrh r0, [r1]\n\ - ands r0, r4\n\ - orrs r0, r3\n\ - strh r0, [r1]\n\ - adds r1, 0x40\n\ - ldrh r0, [r1]\n\ - ands r0, r4\n\ - orrs r0, r3\n\ - strh r0, [r1]\n\ - adds r0, r2, 0x1\n\ - lsls r0, 24\n\ - lsrs r2, r0, 24\n\ - cmp r2, 0x6\n\ - bls _080BFD3E\n\ - lsls r0, r6, 24\n\ - lsrs r1, r0, 24\n\ - cmp r1, 0x3\n\ - bls _080BFD22\n\ - movs r0, 0x1\n\ - bl CopyBgTilemapBufferToVram\n\ - pop {r3}\n\ - mov r8, r3\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ - .syntax divided\n"); -} -#endif -#ifdef NONMATCHING -// This doesn't match because gcc flips the naming of the r3 and r4 -// registers. -void sub_80BFD7C(u8 a, u16 b) +static void HighlightSubmenuScreenSelectBarItem(u8 a, u16 b) { u8 i; u8 j; @@ -3677,10 +3898,13 @@ void sub_80BFD7C(u8 a, u16 b) u8 row = i * 7 + 1; u32 newPalette; - if (i == a || i == 3) - newPalette = 0x2000; - else - newPalette = 0x4000; + do + { + if (i == a || i == 3) + newPalette = 0x2000; + else + newPalette = 0x4000; + } while (0); for (j = 0; j < 7; j++) { @@ -3690,181 +3914,122 @@ void sub_80BFD7C(u8 a, u16 b) } CopyBgTilemapBufferToVram(1); } -#else -__attribute__((naked)) -void sub_80BFD7C(u8 a, u16 b) -{ - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r8\n\ - push {r7}\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - mov r8, r0\n\ - movs r0, 0x1\n\ - bl GetBgTilemapBuffer\n\ - adds r7, r0, 0\n\ - movs r1, 0\n\ -_080BFD92:\n\ - lsls r0, r1, 3\n\ - subs r0, r1\n\ - adds r0, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - cmp r1, r8\n\ - beq _080BFDA4\n\ - cmp r1, 0x3\n\ - bne _080BFDAA\n\ -_080BFDA4:\n\ - movs r3, 0x80\n\ - lsls r3, 6\n\ - b _080BFDAE\n\ -_080BFDAA:\n\ - movs r3, 0x80\n\ - lsls r3, 7\n\ -_080BFDAE:\n\ - movs r2, 0\n\ - adds r5, r1, 0x1\n\ - ldr r4, =0x00000fff\n\ -_080BFDB4:\n\ - adds r1, r6, r2\n\ - lsls r1, 1\n\ - adds r1, r7\n\ - ldrh r0, [r1]\n\ - ands r0, r4\n\ - orrs r0, r3\n\ - strh r0, [r1]\n\ - adds r1, 0x40\n\ - ldrh r0, [r1]\n\ - ands r0, r4\n\ - orrs r0, r3\n\ - strh r0, [r1]\n\ - adds r0, r2, 0x1\n\ - lsls r0, 24\n\ - lsrs r2, r0, 24\n\ - cmp r2, 0x6\n\ - bls _080BFDB4\n\ - lsls r0, r5, 24\n\ - lsrs r1, r0, 24\n\ - cmp r1, 0x3\n\ - bls _080BFD92\n\ - movs r0, 0x1\n\ - bl CopyBgTilemapBufferToVram\n\ - pop {r3}\n\ - mov r8, r3\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ - .syntax divided\n"); -} -#endif -u8 CreateDexDisplayMonDataTask(u16 dexNum, u32 b, u32 c) -{ - u8 taskId = CreateTask(Task_DisplayNewMonData, 0); +#define tState data[0] +#define tDexNum data[1] +#define tPalTimer data[2] +#define tMonSpriteId data[3] +#define tOtIdLo data[12] +#define tOtIdHi data[13] +#define tPersonalityLo data[14] +#define tPersonalityHi data[15] - gTasks[taskId].data[0] = 0; - gTasks[taskId].data[1] = dexNum; - gTasks[taskId].data[12] = b; - gTasks[taskId].data[13] = b >> 16; - gTasks[taskId].data[14] = c; - gTasks[taskId].data[15] = c >> 16; +u8 DisplayCaughtMonDexPage(u16 dexNum, u32 otId, u32 personality) +{ + u8 taskId = CreateTask(Task_DisplayCaughtMonDexPage, 0); + + gTasks[taskId].tState = 0; + gTasks[taskId].tDexNum = dexNum; + gTasks[taskId].tOtIdLo = otId; + gTasks[taskId].tOtIdHi = otId >> 16; + gTasks[taskId].tPersonalityLo = personality; + gTasks[taskId].tPersonalityHi = personality >> 16; return taskId; } -static void Task_DisplayNewMonData(u8 taskId) +static void Task_DisplayCaughtMonDexPage(u8 taskId) { u8 spriteId; - u16 dexNum = gTasks[taskId].data[1]; + u16 dexNum = gTasks[taskId].tDexNum; - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { - case 0: - default: - if (!gPaletteFade.active) - { - gUnknown_030060B4 = gMain.vblankCallback; - SetVBlankCallback(NULL); - ResetOtherVideoRegisters(DISPCNT_BG0_ON); - ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, sNewEntryInfoScreen_BgTemplate, 2); - SetBgTilemapBuffer(3, AllocZeroed(0x800)); - SetBgTilemapBuffer(2, AllocZeroed(0x800)); - InitWindows(sNewEntryInfoScreen_WindowTemplates); - DeactivateAllTextPrinters(); - gTasks[taskId].data[0] = 1; - } - break; - case 1: - DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0); - CopyToBgTilemapBuffer(3, gPokedexTilemap_DescriptionScreen, 0, 0); - FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0)); - PutWindowTilemap(WIN_INFO); - PutWindowTilemap(WIN_FOOTPRINT); - PrintFootprint(WIN_FOOTPRINT, gTasks[taskId].data[1]); - CopyWindowToVram(WIN_FOOTPRINT, 2); - ResetPaletteFade(); - LoadPokedexBgPalette(0); - gTasks[taskId].data[0]++; - break; - case 2: - gTasks[taskId].data[0]++; - break; - case 3: - PrintMonInfo(dexNum, IsNationalPokedexEnabled(), 1, 1); - CopyWindowToVram(WIN_INFO, 3); - CopyBgTilemapBufferToVram(2); - CopyBgTilemapBufferToVram(3); - gTasks[taskId].data[0]++; - break; - case 4: - spriteId = CreateMonSpriteFromNationalDexNumber(dexNum, 48, 56, 0); - gSprites[spriteId].oam.priority = 0; - BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); - SetVBlankCallback(gUnknown_030060B4); - gTasks[taskId].data[3] = spriteId; - gTasks[taskId].data[0]++; - break; - case 5: - SetGpuReg(REG_OFFSET_BLDCNT, 0); - SetGpuReg(REG_OFFSET_BLDALPHA, 0); - SetGpuReg(REG_OFFSET_BLDY, 0); - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); - ShowBg(2); - ShowBg(3); - gTasks[taskId].data[0]++; - break; - case 6: - if (!gPaletteFade.active) - { - PlayCry1(NationalPokedexNumToSpecies(dexNum), 0); - gTasks[taskId].data[2] = 0; - gTasks[taskId].func = sub_80C0088; - } - break; + case 0: + default: + if (!gPaletteFade.active) + { + gPokedexVBlankCB = gMain.vblankCallback; + SetVBlankCallback(NULL); + ResetOtherVideoRegisters(DISPCNT_BG0_ON); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, sNewEntryInfoScreen_BgTemplate, ARRAY_COUNT(sNewEntryInfoScreen_BgTemplate)); + SetBgTilemapBuffer(3, AllocZeroed(0x800)); + SetBgTilemapBuffer(2, AllocZeroed(0x800)); + InitWindows(sNewEntryInfoScreen_WindowTemplates); + DeactivateAllTextPrinters(); + gTasks[taskId].tState = 1; + } + break; + case 1: + DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0); + CopyToBgTilemapBuffer(3, gPokedexInfoScreen_Tilemap, 0, 0); + FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0)); + PutWindowTilemap(WIN_INFO); + PutWindowTilemap(WIN_FOOTPRINT); + PrintFootprint(WIN_FOOTPRINT, gTasks[taskId].tDexNum); + CopyWindowToVram(WIN_FOOTPRINT, 2); + ResetPaletteFade(); + LoadPokedexBgPalette(FALSE); + gTasks[taskId].tState++; + break; + case 2: + gTasks[taskId].tState++; + break; + case 3: + PrintMonInfo(dexNum, IsNationalPokedexEnabled(), 1, 1); + CopyWindowToVram(WIN_INFO, 3); + CopyBgTilemapBufferToVram(2); + CopyBgTilemapBufferToVram(3); + gTasks[taskId].tState++; + break; + case 4: + spriteId = CreateMonSpriteFromNationalDexNumber(dexNum, 48, 56, 0); + gSprites[spriteId].oam.priority = 0; + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); + SetVBlankCallback(gPokedexVBlankCB); + gTasks[taskId].tMonSpriteId = spriteId; + gTasks[taskId].tState++; + break; + case 5: + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); + ShowBg(2); + ShowBg(3); + gTasks[taskId].tState++; + break; + case 6: + if (!gPaletteFade.active) + { + PlayCry1(NationalPokedexNumToSpecies(dexNum), 0); + gTasks[taskId].tPalTimer = 0; + gTasks[taskId].func = Task_HandleCaughtMonPageInput; + } + break; } } -void sub_80C0088(u8 taskId) +static void Task_HandleCaughtMonPageInput(u8 taskId) { if (gMain.newKeys & (A_BUTTON | B_BUTTON)) { BeginNormalPaletteFade(0x0000FFFF, 0, 0, 16, RGB_BLACK); - gSprites[gTasks[taskId].data[3]].callback = sub_80C01CC; - gTasks[taskId].func = blockset_load_palette_to_gpu; + gSprites[gTasks[taskId].tMonSpriteId].callback = SpriteCB_SlideCaughtMonToCenter; + gTasks[taskId].func = Task_ExitCaughtMonPage; } - else if (++gTasks[taskId].data[2] & 0x10) + // Flicker caught screen color + else if (++gTasks[taskId].tPalTimer & 16) { - LoadPalette(gPokedexText_Pal + 1, 0x31, 14); + LoadPalette(gPokedexBgHoenn_Pal + 1, 0x31, 14); } else { - LoadPalette(gPokedexCaughtScreenFade_Pal + 1, 0x31, 14); + LoadPalette(gPokedexCaughtScreen_Pal + 1, 0x31, 14); } } -void blockset_load_palette_to_gpu(u8 taskId) +static void Task_ExitCaughtMonPage(u8 taskId) { if (!gPaletteFade.active) { @@ -3884,17 +4049,17 @@ void blockset_load_palette_to_gpu(u8 taskId) if (buffer) Free(buffer); - species = NationalPokedexNumToSpecies(gTasks[taskId].data[1]); - otId = ((u16)gTasks[taskId].data[13] << 16) | (u16)gTasks[taskId].data[12]; - personality = ((u16)gTasks[taskId].data[15] << 16) | (u16)gTasks[taskId].data[14]; - paletteNum = gSprites[gTasks[taskId].data[3]].oam.paletteNum; + species = NationalPokedexNumToSpecies(gTasks[taskId].tDexNum); + otId = ((u16)gTasks[taskId].tOtIdHi << 16) | (u16)gTasks[taskId].tOtIdLo; + personality = ((u16)gTasks[taskId].tPersonalityHi << 16) | (u16)gTasks[taskId].tPersonalityLo; + paletteNum = gSprites[gTasks[taskId].tMonSpriteId].oam.paletteNum; lzPaletteData = GetMonSpritePalFromSpeciesAndPersonality(species, otId, personality); LoadCompressedPalette(lzPaletteData, 0x100 | paletteNum * 16, 32); DestroyTask(taskId); } } -void sub_80C01CC(struct Sprite *sprite) +static void SpriteCB_SlideCaughtMonToCenter(struct Sprite *sprite) { if (sprite->pos1.x < 0x78) sprite->pos1.x += 2; @@ -3907,41 +4072,51 @@ void sub_80C01CC(struct Sprite *sprite) sprite->pos1.y -= 1; } +#undef tState +#undef tDexNum +#undef tPalTimer +#undef tMonSpriteId +#undef tOtIdLo +#undef tOtIdHi +#undef tPersonalityLo +#undef tPersonalityHi + +// u32 value is re-used, but passed as a bool that's TRUE if national dex is enabled static void PrintMonInfo(u32 num, u32 value, u32 owned, u32 newEntry) { - u8 str[0x10]; - u8 str2[0x20]; + u8 str[16]; + u8 str2[32]; u16 natNum; - const u8 *text; - const u8 *text2; - const u8 *text3; + const u8 *name; + const u8 *category; + const u8 *description; if (newEntry) - PrintInfoPageText(gText_PokedexRegistration, GetStringCenterAlignXOffset(1, gText_PokedexRegistration, 0xF0), 0); + PrintInfoScreenText(gText_PokedexRegistration, GetStringCenterAlignXOffset(1, gText_PokedexRegistration, 0xF0), 0); if (value == 0) value = NationalToHoennOrder(num); else value = num; ConvertIntToDecimalStringN(StringCopy(str, gText_NumberClear01), value, STR_CONV_MODE_LEADING_ZEROS, 3); - PrintInfoPageText(str, 0x60, 0x19); + PrintInfoScreenText(str, 0x60, 0x19); natNum = NationalPokedexNumToSpecies(num); if (natNum) - text = gSpeciesNames[natNum]; + name = gSpeciesNames[natNum]; else - text = sText_TenDashes2; - PrintInfoPageText(text, 0x84, 0x19); + name = sText_TenDashes2; + PrintInfoScreenText(name, 0x84, 0x19); if (owned) { CopyMonCategoryText(num, str2); - text2 = str2; + category = str2; } else { - text2 = gText_5MarksPokemon; + category = gText_5MarksPokemon; } - PrintInfoPageText(text2, 0x64, 0x29); - PrintInfoPageText(gText_HTHeight, 0x60, 0x39); - PrintInfoPageText(gText_WTWeight, 0x60, 0x49); + PrintInfoScreenText(category, 0x64, 0x29); + PrintInfoScreenText(gText_HTHeight, 0x60, 0x39); + PrintInfoScreenText(gText_WTWeight, 0x60, 0x49); if (owned) { PrintMonHeight(gPokedexEntries[num].height, 0x81, 0x39); @@ -3949,14 +4124,14 @@ static void PrintMonInfo(u32 num, u32 value, u32 owned, u32 newEntry) } else { - PrintInfoPageText(gText_UnkHeight, 0x81, 0x39); - PrintInfoPageText(gText_UnkWeight, 0x81, 0x49); + PrintInfoScreenText(gText_UnkHeight, 0x81, 0x39); + PrintInfoScreenText(gText_UnkWeight, 0x81, 0x49); } if (owned) - text3 = gPokedexEntries[num].description; + description = gPokedexEntries[num].description; else - text3 = gExpandedPlaceholder_PokedexDescription; - PrintInfoPageText(text3, GetStringCenterAlignXOffset(1, text3, 0xF0), 0x5F); + description = gExpandedPlaceholder_PokedexDescription; + PrintInfoScreenText(description, GetStringCenterAlignXOffset(1, description, 0xF0), 0x5F); } static void PrintMonHeight(u16 height, u8 left, u8 top) @@ -3989,14 +4164,15 @@ static void PrintMonHeight(u16 height, u8 left, u8 top) buffer[i++] = (inches % 10) + CHAR_0; buffer[i++] = CHAR_DBL_QUOT_RIGHT; buffer[i++] = EOS; - PrintInfoPageText(buffer, left, top); + PrintInfoScreenText(buffer, left, top); } -#ifdef NONMATCHING -// This doesn't match because gcc manages to avoid using the stack -// to store local variables. static void PrintMonWeight(u16 weight, u8 left, u8 top) { +#ifndef NONMATCHING + asm("":::"r9"); +{ +#endif u8 buffer[16]; bool8 output; u8 i = 0; @@ -4051,227 +4227,11 @@ static void PrintMonWeight(u16 weight, u8 left, u8 top) buffer[i++] = CHAR_s; buffer[i++] = CHAR_PERIOD; buffer[i++] = EOS; - PrintInfoPageText(buffer, left, top); -} -#else -__attribute__((naked)) -static void PrintMonWeight(u16 weight, u8 left, u8 top) -{ - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0x14\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - lsls r1, 24\n\ - lsrs r1, 24\n\ - mov r10, r1\n\ - lsls r2, 24\n\ - lsrs r2, 24\n\ - str r2, [sp, 0x10]\n\ - ldr r5, =0x000186a0\n\ - muls r0, r5\n\ - ldr r1, =0x000011b8\n\ - bl __divsi3\n\ - adds r7, r0, 0\n\ - movs r1, 0xA\n\ - bl __umodsi3\n\ - cmp r0, 0x4\n\ - bls _080C0494\n\ - adds r7, 0xA\n\ -_080C0494:\n\ - movs r0, 0\n\ - mov r8, r0\n\ - mov r4, sp\n\ - adds r0, r7, 0\n\ - adds r1, r5, 0\n\ - bl __udivsi3\n\ - adds r0, 0xA1\n\ - strb r0, [r4]\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - cmp r0, 0xA1\n\ - bne _080C04C0\n\ - movs r6, 0x1\n\ - mov r1, sp\n\ - movs r0, 0x77\n\ - strb r0, [r1]\n\ - b _080C04C6\n\ - .pool\n\ -_080C04C0:\n\ - movs r1, 0x1\n\ - mov r8, r1\n\ - movs r6, 0x1\n\ -_080C04C6:\n\ - ldr r1, =0x000186a0\n\ - adds r0, r7, 0\n\ - bl __umodsi3\n\ - adds r7, r0, 0\n\ - mov r4, sp\n\ - adds r4, 0x1\n\ - ldr r1, =0x00002710\n\ - bl __udivsi3\n\ - adds r0, 0xA1\n\ - strb r0, [r4]\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - cmp r0, 0xA1\n\ - bne _080C0504\n\ - mov r2, r8\n\ - cmp r2, 0\n\ - bne _080C0504\n\ - adds r1, r6, 0\n\ - adds r0, r1, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - add r1, sp\n\ - movs r0, 0x77\n\ - strb r0, [r1]\n\ - b _080C050E\n\ - .pool\n\ -_080C0504:\n\ - movs r3, 0x1\n\ - mov r8, r3\n\ - adds r0, r6, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ -_080C050E:\n\ - ldr r1, =0x00002710\n\ - adds r0, r7, 0\n\ - bl __umodsi3\n\ - adds r7, r0, 0\n\ - mov r0, sp\n\ - adds r4, r0, r6\n\ - movs r1, 0xFA\n\ - lsls r1, 2\n\ - adds r0, r7, 0\n\ - bl __udivsi3\n\ - adds r0, 0xA1\n\ - strb r0, [r4]\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - cmp r0, 0xA1\n\ - bne _080C054C\n\ - mov r1, r8\n\ - cmp r1, 0\n\ - bne _080C054C\n\ - adds r1, r6, 0\n\ - adds r0, r1, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - add r1, sp\n\ - movs r0, 0x77\n\ - strb r0, [r1]\n\ - b _080C0552\n\ - .pool\n\ -_080C054C:\n\ - adds r0, r6, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ -_080C0552:\n\ - movs r1, 0xFA\n\ - lsls r1, 2\n\ - adds r0, r7, 0\n\ - bl __umodsi3\n\ - adds r7, r0, 0\n\ - adds r1, r6, 0\n\ - adds r0, r1, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - adds r5, r6, 0\n\ - mov r2, sp\n\ - adds r4, r2, r1\n\ - adds r0, r7, 0\n\ - movs r1, 0x64\n\ - bl __udivsi3\n\ - adds r0, 0xA1\n\ - movs r3, 0\n\ - mov r9, r3\n\ - strb r0, [r4]\n\ - adds r0, r7, 0\n\ - movs r1, 0x64\n\ - bl __umodsi3\n\ - adds r7, r0, 0\n\ - adds r0, r5, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - adds r1, r6, 0\n\ - mov r2, sp\n\ - adds r0, r2, r5\n\ - movs r3, 0xAD\n\ - mov r8, r3\n\ - mov r2, r8\n\ - strb r2, [r0]\n\ - adds r0, r1, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - adds r5, r6, 0\n\ - mov r3, sp\n\ - adds r4, r3, r1\n\ - adds r0, r7, 0\n\ - movs r1, 0xA\n\ - bl __udivsi3\n\ - adds r0, 0xA1\n\ - strb r0, [r4]\n\ - adds r0, r5, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - adds r1, r6, 0\n\ - mov r2, sp\n\ - adds r0, r2, r5\n\ - mov r3, r9\n\ - strb r3, [r0]\n\ - adds r0, r1, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - adds r2, r6, 0\n\ - add r1, sp\n\ - movs r0, 0xE0\n\ - strb r0, [r1]\n\ - adds r0, r2, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - adds r3, r6, 0\n\ - mov r0, sp\n\ - adds r1, r0, r2\n\ - movs r0, 0xD6\n\ - strb r0, [r1]\n\ - adds r0, r3, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - adds r2, r6, 0\n\ - mov r0, sp\n\ - adds r1, r0, r3\n\ - movs r0, 0xE7\n\ - strb r0, [r1]\n\ - adds r0, r2, 0x1\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - mov r3, sp\n\ - adds r1, r3, r2\n\ - mov r2, r8\n\ - strb r2, [r1]\n\ - adds r1, r3, r0\n\ - movs r0, 0xFF\n\ - strb r0, [r1]\n\ - mov r0, sp\n\ - mov r1, r10\n\ - ldr r2, [sp, 0x10]\n\ - bl PrintInfoPageText\n\ - add sp, 0x14\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .syntax divided\n"); + PrintInfoScreenText(buffer, left, top); +#ifndef NONMATCHING } #endif +} const u8 *GetPokedexCategoryName(u16 dexNum) // unused { @@ -4419,6 +4379,7 @@ bool16 HasAllHoennMons(void) { u16 i; + // -2 excludes Jirachi and Deoxys for (i = 0; i < HOENN_DEX_COUNT - 2; i++) { if (!GetSetPokedexFlag(HoennToNationalOrder(i + 1), FLAG_GET_CAUGHT)) @@ -4431,6 +4392,7 @@ bool8 HasAllKantoMons(void) { u16 i; + // -1 excludes Mew for (i = 0; i < KANTO_DEX_COUNT - 1; i++) { if (!GetSetPokedexFlag(i + 1, FLAG_GET_CAUGHT)) @@ -4443,17 +4405,22 @@ bool16 HasAllMons(void) { u16 i; - for (i = 0; i < NATIONAL_DEX_MEWTWO; i++) + // -1 excludes Mew + for (i = 0; i < KANTO_DEX_COUNT - 1; i++) { if (!GetSetPokedexFlag(i + 1, FLAG_GET_CAUGHT)) return FALSE; } - for (i = NATIONAL_DEX_MEW; i < NATIONAL_DEX_TYRANITAR; i++) + + // -3 excludes Lugia, Ho-Oh, and Celebi + for (i = KANTO_DEX_COUNT; i < JOHTO_DEX_COUNT - 3; i++) { if (!GetSetPokedexFlag(i + 1, FLAG_GET_CAUGHT)) return FALSE; } - for (i = NATIONAL_DEX_CELEBI; i < NATIONAL_DEX_RAYQUAZA; i++) + + // -2 excludes Jirachi and Deoxys + for (i = JOHTO_DEX_COUNT; i < NATIONAL_DEX_COUNT - 2; i++) { if (!GetSetPokedexFlag(i + 1, FLAG_GET_CAUGHT)) return FALSE; @@ -4500,67 +4467,67 @@ static void ResetOtherVideoRegisters(u16 a) } } -void sub_80C0A88(u8 windowId, const u8 *str, u8 left, u8 top) +static void PrintInfoSubMenuText(u8 windowId, const u8 *str, u8 left, u8 top) { u8 color[3]; - color[0] = 0; - color[1] = 15; - color[2] = 3; + color[0] = TEXT_COLOR_TRANSPARENT; + color[1] = TEXT_DYNAMIC_COLOR_6; + color[2] = TEXT_COLOR_LIGHT_GREY; AddTextPrinterParameterized4(windowId, 1, left, top, 0, 0, color, -1, str); } -void sub_80C0AC4(u8 windowId, u16 order, u8 left, u8 top) // unused +static void UnusedPrintNum(u8 windowId, u16 num, u8 left, u8 top) { u8 str[4]; - str[0] = CHAR_0 + order / 100; - str[1] = CHAR_0 + (order % 100) / 10; - str[2] = CHAR_0 + (order % 100) % 10; + str[0] = CHAR_0 + num / 100; + str[1] = CHAR_0 + (num % 100) / 10; + str[2] = CHAR_0 + (num % 100) % 10; str[3] = EOS; - sub_80C0A88(windowId, str, left, top); + PrintInfoSubMenuText(windowId, str, left, top); } -u8 sub_80C0B44(u8 windowId, u16 num, u8 left, u8 top) +static u8 PrintCryScreenSpeciesName(u8 windowId, u16 num, u8 left, u8 top) { - u8 str[11]; + u8 str[POKEMON_NAME_LENGTH + 1]; u8 i; - for (i = 0; i < 11; i++) + for (i = 0; i < ARRAY_COUNT(str); i++) str[i] = EOS; num = NationalPokedexNumToSpecies(num); switch (num) { - default: - for (i = 0; gSpeciesNames[num][i] != EOS && i < 10; i++) - str[i] = gSpeciesNames[num][i]; - break; - case 0: - for (i = 0; i < 5; i++) - str[i] = CHAR_HYPHEN; - break; + default: + for (i = 0; gSpeciesNames[num][i] != EOS && i < POKEMON_NAME_LENGTH; i++) + str[i] = gSpeciesNames[num][i]; + break; + case 0: + for (i = 0; i < 5; i++) + str[i] = CHAR_HYPHEN; + break; } - sub_80C0A88(windowId, str, left, top); + PrintInfoSubMenuText(windowId, str, left, top); return i; } -void sub_80C0BF0(u8 windowId, const u8* str, u8 left, u8 top) // unused +static void UnusedPrintMonName(u8 windowId, const u8* name, u8 left, u8 top) { - u8 str2[11]; + u8 str[POKEMON_NAME_LENGTH + 1]; u8 i; - u8 count; + u8 nameLength; - for (i = 0; i < 11; i++) - str2[i] = CHAR_SPACE; - for (count = 0; str[count] != CHAR_SPACE && count < 11; count++) + for (i = 0; i < ARRAY_COUNT(str); i++) + str[i] = CHAR_SPACE; + for (nameLength = 0; name[nameLength] != CHAR_SPACE && nameLength < ARRAY_COUNT(str); nameLength++) ; - for (i = 0; i < count; i++) - str2[11 - count + i] = str[i]; - str2[11] = EOS; - sub_80C0A88(windowId, str2, left, top); + for (i = 0; i < nameLength; i++) + str[ARRAY_COUNT(str) - nameLength + i] = name[i]; + str[ARRAY_COUNT(str)] = EOS; + PrintInfoSubMenuText(windowId, str, left, top); } -void sub_80C0C6C(u8 windowId, u16 b, u8 left, u8 top) // unused +static void UnusedPrintDecimalNum(u8 windowId, u16 b, u8 left, u8 top) { u8 str[6]; bool8 outputted = FALSE; @@ -4594,7 +4561,7 @@ void sub_80C0C6C(u8 windowId, u16 b, u8 left, u8 top) // unused str[3] = CHAR_PERIOD; str[4] = CHAR_0 + ((b % 1000) % 100) % 10; str[5] = EOS; - sub_80C0A88(windowId, str, left, top); + PrintInfoSubMenuText(windowId, str, left, top); } static void PrintFootprint(u8 windowId, u16 dexNum) @@ -4620,6 +4587,7 @@ static void PrintFootprint(u8 windowId, u16 dexNum) CopyToWindowPixelBuffer(windowId, image, sizeof(image), 0); } +// Unused void sub_80C0DC0(u16 a, u16 b) { *(u16 *)(VRAM + a * 0x800 + 0x232) = 0xF000 + b + 0; @@ -4628,39 +4596,41 @@ void sub_80C0DC0(u16 a, u16 b) *(u16 *)(VRAM + a * 0x800 + 0x274) = 0xF000 + b + 3; } -u16 sub_80C0E0C(u8 a, u16 b, u16 c, u16 d) +static u16 GetNextPosition(u8 direction, u16 position, u16 min, u16 max) { - switch (a) + switch (direction) { - case 1: - if (b > c) - b--; - break; - case 0: - if (b < d) - b++; - break; - case 3: - if (b > c) - b--; - else - b = d; - break; - case 2: - if (b < d) - b++; - else - b = c; - break; + case 1: // Up/Left + if (position > min) + position--; + break; + case 0: // Down/Right + if (position < max) + position++; + break; + case 3: // Up/Left with loop (unused) + if (position > min) + position--; + else + position = max; + break; + case 2: // Down/Right with loop (unused) + if (position < max) + position++; + else + position = min; + break; } - return b; + return position; } -u32 sub_80C0E68(u16 a) +// Unown and Spinda use the personality of the first seen individual of that species +// All others use personality 0 +static u32 GetPokedexMonPersonality(u16 species) { - if (a == SPECIES_UNOWN || a == SPECIES_SPINDA) + if (species == SPECIES_UNOWN || species == SPECIES_SPINDA) { - if (a == SPECIES_UNOWN) + if (species == SPECIES_UNOWN) return gSaveBlock2Ptr->pokedex.unownPersonality; else return gSaveBlock2Ptr->pokedex.spindaPersonality; @@ -4674,22 +4644,22 @@ u32 sub_80C0E68(u16 a) u16 CreateMonSpriteFromNationalDexNumber(u16 nationalNum, s16 x, s16 y, u16 paletteSlot) { nationalNum = NationalPokedexNumToSpecies(nationalNum); - return CreateMonPicSprite_HandleDeoxys(nationalNum, SHINY_ODDS, sub_80C0E68(nationalNum), TRUE, x, y, paletteSlot, 0xFFFF); + return CreateMonPicSprite_HandleDeoxys(nationalNum, SHINY_ODDS, GetPokedexMonPersonality(nationalNum), TRUE, x, y, paletteSlot, 0xFFFF); } -u16 sub_80C0EF8(u16 species, s16 x, s16 y, s8 paletteSlot) +static u16 CreateSizeScreenTrainerPic(u16 species, s16 x, s16 y, s8 paletteSlot) { return CreateTrainerPicSprite(species, TRUE, x, y, paletteSlot, 0xFFFF); } -int sub_80C0F30(u8 dexMode, u8 sortMode, u8 abcGroup, u8 bodyColor, u8 type1, u8 type2) +static int DoPokedexSearch(u8 dexMode, u8 order, u8 abcGroup, u8 bodyColor, u8 type1, u8 type2) { u16 species; u16 i; u16 resultsCount; u8 types[2]; - CreatePokedexList(dexMode, sortMode); + CreatePokedexList(dexMode, order); for (i = 0, resultsCount = 0; i < NATIONAL_DEX_COUNT; i++) { @@ -4706,12 +4676,11 @@ int sub_80C0F30(u8 dexMode, u8 sortMode, u8 abcGroup, u8 bodyColor, u8 type1, u8 { for (i = 0, resultsCount = 0; i < sPokedexView->pokemonListCount; i++) { - u8 r3; + u8 firstLetter; species = NationalPokedexNumToSpecies(sPokedexView->pokedexList[i].dexNum); - r3 = gSpeciesNames[species][0]; - if ((r3 >= gUnknown_0856ED08[abcGroup][0] && r3 < gUnknown_0856ED08[abcGroup][0] + gUnknown_0856ED08[abcGroup][1]) - || (r3 >= gUnknown_0856ED08[abcGroup][2] && r3 < gUnknown_0856ED08[abcGroup][2] + gUnknown_0856ED08[abcGroup][3])) + firstLetter = gSpeciesNames[species][0]; + if (LETTER_IN_RANGE_UPPER(firstLetter, abcGroup) || LETTER_IN_RANGE_LOWER(firstLetter, abcGroup)) { sPokedexView->pokedexList[resultsCount] = sPokedexView->pokedexList[i]; resultsCount++; @@ -4797,98 +4766,116 @@ int sub_80C0F30(u8 dexMode, u8 sortMode, u8 abcGroup, u8 bodyColor, u8 type1, u8 return resultsCount; } -u8 LoadSearchMenu(void) +static u8 LoadSearchMenu(void) { return CreateTask(Task_LoadSearchMenu, 0); } -void sub_80C1270(const u8 *str, u32 left, u32 top) +static void PrintSearchText(const u8 *str, u32 x, u32 y) { u8 color[3]; - color[0] = 0; - color[1] = 15; - color[2] = 2; - AddTextPrinterParameterized4(0, 1, left, top, 0, 0, color, -1, str); + color[0] = TEXT_COLOR_TRANSPARENT; + color[1] = TEXT_DYNAMIC_COLOR_6; + color[2] = TEXT_COLOR_DARK_GREY; + AddTextPrinterParameterized4(0, 1, x, y, 0, 0, color, -1, str); } -void sub_80C12B0(u32 x, u32 y, u32 width, u32 height) +static void ClearSearchMenuRect(u32 x, u32 y, u32 width, u32 height) { FillWindowPixelRect(0, PIXEL_FILL(0), x, y, width, height); } -void Task_LoadSearchMenu(u8 taskId) +// Search task data +#define tTopBarItem data[0] +#define tMenuItem data[1] +#define tCursorPos_Mode data[2] +#define tScrollOffset_Mode data[3] +#define tCursorPos_Order data[4] +#define tScrollOffset_Order data[5] +#define tCursorPos_Name data[6] +#define tScrollOffset_Name data[7] +#define tCursorPos_Color data[8] +#define tScrollOffset_Color data[9] +#define tCursorPos_TypeLeft data[10] +#define tScrollOffset_TypeLeft data[11] +#define tCursorPos_TypeRight data[12] +#define tScrollOffset_TypeRight data[13] +#define tCursorPos data[14] +#define tScrollOffset data[15] + +static void Task_LoadSearchMenu(u8 taskId) { u16 i; switch (gMain.state) { - default: - case 0: - if (!gPaletteFade.active) - { - sPokedexView->unk64A = 2; - ResetOtherVideoRegisters(0); - ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, sSearchMenu_BgTemplate, 4); - SetBgTilemapBuffer(3, AllocZeroed(0x800)); - SetBgTilemapBuffer(2, AllocZeroed(0x800)); - SetBgTilemapBuffer(1, AllocZeroed(0x800)); - SetBgTilemapBuffer(0, AllocZeroed(0x800)); - InitWindows(sSearchMenu_WindowTemplate); - DeactivateAllTextPrinters(); - PutWindowTilemap(0); - DecompressAndLoadBgGfxUsingHeap(3, gPokedexSearchMenu_Gfx, 0x2000, 0, 0); + default: + case 0: + if (!gPaletteFade.active) + { + sPokedexView->currentPage = PAGE_SEARCH; + ResetOtherVideoRegisters(0); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, sSearchMenu_BgTemplate, ARRAY_COUNT(sSearchMenu_BgTemplate)); + SetBgTilemapBuffer(3, AllocZeroed(0x800)); + SetBgTilemapBuffer(2, AllocZeroed(0x800)); + SetBgTilemapBuffer(1, AllocZeroed(0x800)); + SetBgTilemapBuffer(0, AllocZeroed(0x800)); + InitWindows(sSearchMenu_WindowTemplate); + DeactivateAllTextPrinters(); + PutWindowTilemap(0); + DecompressAndLoadBgGfxUsingHeap(3, gPokedexSearchMenu_Gfx, 0x2000, 0, 0); - if (!IsNationalPokedexEnabled()) - CopyToBgTilemapBuffer(3, gPokedexSearch2_Tilemap, 0, 0); - else - CopyToBgTilemapBuffer(3, gPokedexSearch1_Tilemap, 0, 0); - LoadPalette(gPokedexSearchMenu_Pal + 1, 1, 0x7E); - gMain.state = 1; - } - break; - case 1: - LoadCompressedSpriteSheet(sInterfaceSpriteSheet); - LoadSpritePalettes(sInterfaceSpritePalette); - sub_80C2594(taskId); - for (i = 0; i < 16; i++) - gTasks[taskId].data[i] = 0; - sub_80C23B8(taskId); - sub_80C2040(0); - sub_80C20F8(taskId); - CopyWindowToVram(0, 3); - CopyBgTilemapBufferToVram(1); - CopyBgTilemapBufferToVram(2); - CopyBgTilemapBufferToVram(3); - gMain.state++; - break; - case 2: - BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); - gMain.state++; - break; - case 3: - SetGpuReg(REG_OFFSET_BLDCNT, 0); - SetGpuReg(REG_OFFSET_BLDALPHA, 0); - SetGpuReg(REG_OFFSET_BLDY, 0); - SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); - HideBg(0); - ShowBg(1); - ShowBg(2); - ShowBg(3); - gMain.state++; - break; - case 4: - if (!gPaletteFade.active) - { - gTasks[taskId].func = sub_80C1570; - gMain.state = 0; - } - break; + if (!IsNationalPokedexEnabled()) + CopyToBgTilemapBuffer(3, gPokedexSearchMenuHoenn_Tilemap, 0, 0); + else + CopyToBgTilemapBuffer(3, gPokedexSearchMenuNational_Tilemap, 0, 0); + LoadPalette(gPokedexSearchMenu_Pal + 1, 1, 0x7E); + gMain.state = 1; + } + break; + case 1: + LoadCompressedSpriteSheet(sInterfaceSpriteSheet); + LoadSpritePalettes(sInterfaceSpritePalette); + CreateSearchParameterScrollArrows(taskId); + for (i = 0; i < NUM_TASK_DATA; i++) + gTasks[taskId].data[i] = 0; + SetDefaultSearchModeAndOrder(taskId); + HighlightSelectedSearchTopBarItem(SEARCH_TOPBAR_SEARCH); + PrintSelectedSearchParameters(taskId); + CopyWindowToVram(0, 3); + CopyBgTilemapBufferToVram(1); + CopyBgTilemapBufferToVram(2); + CopyBgTilemapBufferToVram(3); + gMain.state++; + break; + case 2: + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); + gMain.state++; + break; + case 3: + SetGpuReg(REG_OFFSET_BLDCNT, 0); + SetGpuReg(REG_OFFSET_BLDALPHA, 0); + SetGpuReg(REG_OFFSET_BLDY, 0); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); + HideBg(0); + ShowBg(1); + ShowBg(2); + ShowBg(3); + gMain.state++; + break; + case 4: + if (!gPaletteFade.active) + { + gTasks[taskId].func = Task_SwitchToSearchMenuTopBar; + gMain.state = 0; + } + break; } } -void sub_80C152C(void) +static void FreeSearchWindowAndBgBuffers(void) { void* tilemapBuffer; @@ -4907,120 +4894,121 @@ void sub_80C152C(void) Free(tilemapBuffer); } -void sub_80C1570(u8 taskId) +static void Task_SwitchToSearchMenuTopBar(u8 taskId) { - sub_80C2040(gTasks[taskId].data[0]); - sub_80C20F8(taskId); + HighlightSelectedSearchTopBarItem(gTasks[taskId].tTopBarItem); + PrintSelectedSearchParameters(taskId); CopyWindowToVram(0, 2); CopyBgTilemapBufferToVram(3); - gTasks[taskId].func = sub_80C15B0; + gTasks[taskId].func = Task_HandleSearchTopBarInput; } -void sub_80C15B0(u8 taskId) +static void Task_HandleSearchTopBarInput(u8 taskId) { if (gMain.newKeys & B_BUTTON) { PlaySE(SE_PC_OFF); - gTasks[taskId].func = sub_80C1D38; + gTasks[taskId].func = Task_ExitSearch; return; } if (gMain.newKeys & A_BUTTON) { - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tTopBarItem) { - case 0: - PlaySE(SE_PIN); - gTasks[taskId].data[1] = 0; - gTasks[taskId].func = sub_80C16CC; - break; - case 1: - PlaySE(SE_PIN); - gTasks[taskId].data[1] = 4; - gTasks[taskId].func = sub_80C16CC; - break; - case 2: - PlaySE(SE_PC_OFF); - gTasks[taskId].func = sub_80C1D38; - break; + case SEARCH_TOPBAR_SEARCH: + PlaySE(SE_PIN); + gTasks[taskId].tMenuItem = SEARCH_NAME; + gTasks[taskId].func = Task_SwitchToSearchMenu; + break; + case SEARCH_TOPBAR_SHIFT: + PlaySE(SE_PIN); + gTasks[taskId].tMenuItem = SEARCH_ORDER; + gTasks[taskId].func = Task_SwitchToSearchMenu; + break; + case SEARCH_TOPBAR_CANCEL: + PlaySE(SE_PC_OFF); + gTasks[taskId].func = Task_ExitSearch; + break; } return; } - if ((gMain.newKeys & DPAD_LEFT) && gTasks[taskId].data[0] > 0) + if ((gMain.newKeys & DPAD_LEFT) && gTasks[taskId].tTopBarItem > SEARCH_TOPBAR_SEARCH) { PlaySE(SE_Z_PAGE); - gTasks[taskId].data[0]--; - sub_80C2040(gTasks[taskId].data[0]); + gTasks[taskId].tTopBarItem--; + HighlightSelectedSearchTopBarItem(gTasks[taskId].tTopBarItem); CopyWindowToVram(0, 2); CopyBgTilemapBufferToVram(3); } - if ((gMain.newKeys & DPAD_RIGHT) && gTasks[taskId].data[0] < 2) + if ((gMain.newKeys & DPAD_RIGHT) && gTasks[taskId].tTopBarItem < SEARCH_TOPBAR_CANCEL) { PlaySE(SE_Z_PAGE); - gTasks[taskId].data[0]++; - sub_80C2040(gTasks[taskId].data[0]); + gTasks[taskId].tTopBarItem++; + HighlightSelectedSearchTopBarItem(gTasks[taskId].tTopBarItem); CopyWindowToVram(0, 2); CopyBgTilemapBufferToVram(3); } } -void sub_80C16CC(u8 taskId) +static void Task_SwitchToSearchMenu(u8 taskId) { - sub_80C2064(gTasks[taskId].data[0], gTasks[taskId].data[1]); - sub_80C20F8(taskId); + HighlightSelectedSearchMenuItem(gTasks[taskId].tTopBarItem, gTasks[taskId].tMenuItem); + PrintSelectedSearchParameters(taskId); CopyWindowToVram(0, 2); CopyBgTilemapBufferToVram(3); - gTasks[taskId].func = sub_80C170C; + gTasks[taskId].func = Task_HandleSearchMenuInput; } -void sub_80C170C(u8 taskId) +// Input for main search menu +static void Task_HandleSearchMenuInput(u8 taskId) { - const u8 (*r6)[4]; + const u8 (*movementMap)[4]; - if (gTasks[taskId].data[0] != 0) + if (gTasks[taskId].tTopBarItem != SEARCH_TOPBAR_SEARCH) { if (!IsNationalPokedexEnabled()) - r6 = gUnknown_0856EDF0; + movementMap = sSearchMovementMap_ShiftHoennDex; else - r6 = gUnknown_0856EDB8; + movementMap = sSearchMovementMap_ShiftNatDex; } else { if (!IsNationalPokedexEnabled()) - r6 = gUnknown_0856EDD4; + movementMap = sSearchMovementMap_SearchHoennDex; else - r6 = gUnknown_0856ED9C; + movementMap = sSearchMovementMap_SearchNatDex; } if (gMain.newKeys & B_BUTTON) { PlaySE(SE_BOWA); - sub_80C23B8(taskId); - gTasks[taskId].func = sub_80C1570; + SetDefaultSearchModeAndOrder(taskId); + gTasks[taskId].func = Task_SwitchToSearchMenuTopBar; return; } if (gMain.newKeys & A_BUTTON) { - if (gTasks[taskId].data[1] == 6) + if (gTasks[taskId].tMenuItem == SEARCH_OK) { - if (gTasks[taskId].data[0] != 0) + if (gTasks[taskId].tTopBarItem != SEARCH_TOPBAR_SEARCH) { - gUnknown_02039B52 = 0x40; - sPokedexView->unk62A = 0x40; - gUnknown_02039B50 = 0; - sPokedexView->unk610 = 0; - gSaveBlock2Ptr->pokedex.mode = GetSearchModeSelection(taskId, SEARCH_DEX_MODE); + sPokeBallRotation = POKEBALL_ROTATION_TOP; + sPokedexView->pokeBallRotationBackup = POKEBALL_ROTATION_TOP; + sLastSelectedPokemon = 0; + sPokedexView->selectedPokemonBackup = 0; + gSaveBlock2Ptr->pokedex.mode = GetSearchModeSelection(taskId, SEARCH_MODE); if (!IsNationalPokedexEnabled()) gSaveBlock2Ptr->pokedex.mode = DEX_MODE_HOENN; - sPokedexView->unk614 = gSaveBlock2Ptr->pokedex.mode; + sPokedexView->dexModeBackup = gSaveBlock2Ptr->pokedex.mode; gSaveBlock2Ptr->pokedex.order = GetSearchModeSelection(taskId, SEARCH_ORDER); - sPokedexView->unk618 = gSaveBlock2Ptr->pokedex.order; + sPokedexView->dexOrderBackup = gSaveBlock2Ptr->pokedex.order; PlaySE(SE_PC_OFF); - gTasks[taskId].func = sub_80C1D38; + gTasks[taskId].func = Task_ExitSearch; } else { - sub_80C2618(gText_SearchingPleaseWait); - gTasks[taskId].func = sub_80C19A4; + EraseAndPrintSearchTextBox(gText_SearchingPleaseWait); + gTasks[taskId].func = Task_StartPokedexSearch; PlaySE(SE_Z_SEARCH); CopyWindowToVram(0, 2); } @@ -5028,136 +5016,138 @@ void sub_80C170C(u8 taskId) else { PlaySE(SE_PIN); - gTasks[taskId].func = sub_80C1B64; + gTasks[taskId].func = Task_SelectSearchMenuItem; } return; } - if ((gMain.newKeys & DPAD_LEFT) && r6[gTasks[taskId].data[1]][0] != 0xFF) + if ((gMain.newKeys & DPAD_LEFT) && movementMap[gTasks[taskId].tMenuItem][0] != 0xFF) { PlaySE(SE_SELECT); - gTasks[taskId].data[1] = r6[gTasks[taskId].data[1]][0]; - sub_80C2064(gTasks[taskId].data[0], gTasks[taskId].data[1]); + gTasks[taskId].tMenuItem = movementMap[gTasks[taskId].tMenuItem][0]; + HighlightSelectedSearchMenuItem(gTasks[taskId].tTopBarItem, gTasks[taskId].tMenuItem); CopyWindowToVram(0, 2); CopyBgTilemapBufferToVram(3); } - if ((gMain.newKeys & DPAD_RIGHT) && r6[gTasks[taskId].data[1]][1] != 0xFF) + if ((gMain.newKeys & DPAD_RIGHT) && movementMap[gTasks[taskId].tMenuItem][1] != 0xFF) { PlaySE(SE_SELECT); - gTasks[taskId].data[1] = r6[gTasks[taskId].data[1]][1]; - sub_80C2064(gTasks[taskId].data[0], gTasks[taskId].data[1]); + gTasks[taskId].tMenuItem = movementMap[gTasks[taskId].tMenuItem][1]; + HighlightSelectedSearchMenuItem(gTasks[taskId].tTopBarItem, gTasks[taskId].tMenuItem); CopyWindowToVram(0, 2); CopyBgTilemapBufferToVram(3); } - if ((gMain.newKeys & DPAD_UP) && r6[gTasks[taskId].data[1]][2] != 0xFF) + if ((gMain.newKeys & DPAD_UP) && movementMap[gTasks[taskId].tMenuItem][2] != 0xFF) { PlaySE(SE_SELECT); - gTasks[taskId].data[1] = r6[gTasks[taskId].data[1]][2]; - sub_80C2064(gTasks[taskId].data[0], gTasks[taskId].data[1]); + gTasks[taskId].tMenuItem = movementMap[gTasks[taskId].tMenuItem][2]; + HighlightSelectedSearchMenuItem(gTasks[taskId].tTopBarItem, gTasks[taskId].tMenuItem); CopyWindowToVram(0, 2); CopyBgTilemapBufferToVram(3); } - if ((gMain.newKeys & DPAD_DOWN) && r6[gTasks[taskId].data[1]][3] != 0xFF) + if ((gMain.newKeys & DPAD_DOWN) && movementMap[gTasks[taskId].tMenuItem][3] != 0xFF) { PlaySE(SE_SELECT); - gTasks[taskId].data[1] = r6[gTasks[taskId].data[1]][3]; - sub_80C2064(gTasks[taskId].data[0], gTasks[taskId].data[1]); + gTasks[taskId].tMenuItem = movementMap[gTasks[taskId].tMenuItem][3]; + HighlightSelectedSearchMenuItem(gTasks[taskId].tTopBarItem, gTasks[taskId].tMenuItem); CopyWindowToVram(0, 2); CopyBgTilemapBufferToVram(3); } } -void sub_80C19A4(u8 taskId) +static void Task_StartPokedexSearch(u8 taskId) { - u8 dexMode = GetSearchModeSelection(taskId, SEARCH_DEX_MODE); - u8 sortMode = GetSearchModeSelection(taskId, SEARCH_ORDER); + u8 dexMode = GetSearchModeSelection(taskId, SEARCH_MODE); + u8 order = GetSearchModeSelection(taskId, SEARCH_ORDER); u8 abcGroup = GetSearchModeSelection(taskId, SEARCH_NAME); u8 bodyColor = GetSearchModeSelection(taskId, SEARCH_COLOR); - u8 type1 = GetSearchModeSelection(taskId, SEARCH_TYPE_1); - u8 type2 = GetSearchModeSelection(taskId, SEARCH_TYPE_2); + u8 type1 = GetSearchModeSelection(taskId, SEARCH_TYPE_LEFT); + u8 type2 = GetSearchModeSelection(taskId, SEARCH_TYPE_RIGHT); - sub_80C0F30(dexMode, sortMode, abcGroup, bodyColor, type1, type2); - gTasks[taskId].func = sub_80C1A4C; + DoPokedexSearch(dexMode, order, abcGroup, bodyColor, type1, type2); + gTasks[taskId].func = Task_WaitAndCompleteSearch; } -void sub_80C1A4C(u8 taskId) +static void Task_WaitAndCompleteSearch(u8 taskId) { if (!IsSEPlaying()) { if (sPokedexView->pokemonListCount != 0) { PlaySE(SE_SEIKAI); - sub_80C2618(gText_SearchCompleted); + EraseAndPrintSearchTextBox(gText_SearchCompleted); } else { PlaySE(SE_HAZURE); - sub_80C2618(gText_NoMatchingPkmnWereFound); + EraseAndPrintSearchTextBox(gText_NoMatchingPkmnWereFound); } - gTasks[taskId].func = sub_80C1AB8; + gTasks[taskId].func = Task_SearchCompleteWaitForInput; CopyWindowToVram(0, 2); } } -void sub_80C1AB8(u8 taskId) +static void Task_SearchCompleteWaitForInput(u8 taskId) { if (gMain.newKeys & A_BUTTON) { if (sPokedexView->pokemonListCount != 0) { - sPokedexView->unk64E = 1; - sPokedexView->dexMode = GetSearchModeSelection(taskId, SEARCH_DEX_MODE); + // Return to dex list and show search results + sPokedexView->screenSwitchState = 1; + sPokedexView->dexMode = GetSearchModeSelection(taskId, SEARCH_MODE); sPokedexView->dexOrder = GetSearchModeSelection(taskId, SEARCH_ORDER); - gTasks[taskId].func = sub_80C1D38; + gTasks[taskId].func = Task_ExitSearch; PlaySE(SE_PC_OFF); } else { - gTasks[taskId].func = sub_80C16CC; + gTasks[taskId].func = Task_SwitchToSearchMenu; PlaySE(SE_BOWA); } } } -void sub_80C1B64(u8 taskId) +static void Task_SelectSearchMenuItem(u8 taskId) { - u8 r0; - u16 *p1; - u16 *p2; + u8 menuItem; + u16 *cursorPos; + u16 *scrollOffset; - sub_80C21D4(0); - r0 = gTasks[taskId].data[1]; - p1 = &gTasks[taskId].data[sSearchOptions[r0].unk4]; - p2 = &gTasks[taskId].data[sSearchOptions[r0].unk5]; - gTasks[taskId].data[14] = *p1; - gTasks[taskId].data[15] = *p2; - sub_80C2294(taskId); - sub_80C2650(*p1); - gTasks[taskId].func = sub_80C1BCC; + DrawOrEraseSearchParameterBox(FALSE); + menuItem = gTasks[taskId].tMenuItem; + cursorPos = &gTasks[taskId].data[sSearchOptions[menuItem].taskDataCursorPos]; + scrollOffset = &gTasks[taskId].data[sSearchOptions[menuItem].taskDataScrollOffset]; + gTasks[taskId].tCursorPos = *cursorPos; + gTasks[taskId].tScrollOffset = *scrollOffset; + PrintSearchParameterText(taskId); + PrintSelectorArrow(*cursorPos); + gTasks[taskId].func = Task_HandleSearchParameterInput; CopyWindowToVram(0, 2); CopyBgTilemapBufferToVram(3); } -void sub_80C1BCC(u8 taskId) +// Input for scrolling parameter box in right column +static void Task_HandleSearchParameterInput(u8 taskId) { - u8 r1; - const struct PokedexOption *r8; - u16 *p1; - u16 *p2; - u16 r2; - bool8 r3; + u8 menuItem; + const struct SearchOptionText *texts; + u16 *cursorPos; + u16 *scrollOffset; + u16 maxOption; + bool8 moved; - r1 = gTasks[taskId].data[1]; - r8 = sSearchOptions[r1].pokedexList; - p1 = &gTasks[taskId].data[sSearchOptions[r1].unk4]; - p2 = &gTasks[taskId].data[sSearchOptions[r1].unk5]; - r2 = sSearchOptions[r1].numOptions - 1; + menuItem = gTasks[taskId].tMenuItem; + texts = sSearchOptions[menuItem].texts; + cursorPos = &gTasks[taskId].data[sSearchOptions[menuItem].taskDataCursorPos]; + scrollOffset = &gTasks[taskId].data[sSearchOptions[menuItem].taskDataScrollOffset]; + maxOption = sSearchOptions[menuItem].numOptions - 1; if (gMain.newKeys & A_BUTTON) { PlaySE(SE_PIN); - sub_80C267C(); - sub_80C21D4(1); - gTasks[taskId].func = sub_80C16CC; + ClearSearchParameterBoxText(); + DrawOrEraseSearchParameterBox(TRUE); + gTasks[taskId].func = Task_SwitchToSearchMenu; CopyWindowToVram(0, 2); CopyBgTilemapBufferToVram(3); return; @@ -5165,77 +5155,81 @@ void sub_80C1BCC(u8 taskId) if (gMain.newKeys & B_BUTTON) { PlaySE(SE_BOWA); - sub_80C267C(); - sub_80C21D4(1); - *p1 = gTasks[taskId].data[14]; - *p2 = gTasks[taskId].data[15]; - gTasks[taskId].func = sub_80C16CC; + ClearSearchParameterBoxText(); + DrawOrEraseSearchParameterBox(TRUE); + *cursorPos = gTasks[taskId].tCursorPos; + *scrollOffset = gTasks[taskId].tScrollOffset; + gTasks[taskId].func = Task_SwitchToSearchMenu; CopyWindowToVram(0, 2); CopyBgTilemapBufferToVram(3); return; } - r3 = FALSE; + moved = FALSE; if (gMain.newAndRepeatedKeys & DPAD_UP) { - if (*p1 != 0) + if (*cursorPos != 0) { - sub_80C2638(*p1); - (*p1)--; - sub_80C2650(*p1); - r3 = TRUE; + // Move cursor up + EraseSelectorArrow(*cursorPos); + (*cursorPos)--; + PrintSelectorArrow(*cursorPos); + moved = TRUE; } - else if (*p2 != 0) + else if (*scrollOffset != 0) { - (*p2)--; - sub_80C2294(taskId); - sub_80C2650(*p1); - r3 = TRUE; + // Scroll up + (*scrollOffset)--; + PrintSearchParameterText(taskId); + PrintSelectorArrow(*cursorPos); + moved = TRUE; } - if (r3) + if (moved) { PlaySE(SE_SELECT); - sub_80C2618(r8[*p1 + *p2].description); + EraseAndPrintSearchTextBox(texts[*cursorPos + *scrollOffset].description); CopyWindowToVram(0, 2); } return; } if (gMain.newAndRepeatedKeys & DPAD_DOWN) { - if (*p1 < 5 && *p1 < r2) + if (*cursorPos < MAX_SEARCH_PARAM_CURSOR_POS && *cursorPos < maxOption) { - sub_80C2638(*p1); - (*p1)++; - sub_80C2650(*p1); - r3 = TRUE; + // Move cursor down + EraseSelectorArrow(*cursorPos); + (*cursorPos)++; + PrintSelectorArrow(*cursorPos); + moved = TRUE; } - else if (r2 > 5 && *p2 < r2 - 5) + else if (maxOption > MAX_SEARCH_PARAM_CURSOR_POS && *scrollOffset < maxOption - MAX_SEARCH_PARAM_CURSOR_POS) { - (*p2)++; - sub_80C2294(taskId); - sub_80C2650(5); - r3 = TRUE; + // Scroll down + (*scrollOffset)++; + PrintSearchParameterText(taskId); + PrintSelectorArrow(5); + moved = TRUE; } - if (r3) + if (moved) { PlaySE(SE_SELECT); - sub_80C2618(r8[*p1 + *p2].description); + EraseAndPrintSearchTextBox(texts[*cursorPos + *scrollOffset].description); CopyWindowToVram(0, 2); } return; } } -void sub_80C1D38(u8 taskId) +static void Task_ExitSearch(u8 taskId) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); - gTasks[taskId].func = sub_80C1D70; + gTasks[taskId].func = Task_ExitSearchWaitForFade; } -void sub_80C1D70(u8 taskId) +static void Task_ExitSearchWaitForFade(u8 taskId) { if (!gPaletteFade.active) { - sub_80C152C(); + FreeSearchWindowAndBgBuffers(); DestroyTask(taskId); } } @@ -5243,27 +5237,27 @@ void sub_80C1D70(u8 taskId) #ifdef NONMATCHING // This doesn't match because gcc flips the naming of the r7 and r6 // registers. It also does one of the additions backwards. -void sub_80C1D98(u8 a, u8 b, u8 c, u8 d) +void SetSearchRectHighlight(u8 flags, u8 x, u8 y, u8 width) { u16 i; u16* ptr = GetBgTilemapBuffer(3); u16* temp; - for (i = 0; i < d; i++) + for (i = 0; i < width; i++) { // This addition is supposed to be done in this order; however, - // gcc will always do it in ptr + (c << 5) order. - temp = (c << 5) + ptr; - temp[b + i] %= 0x1000; - temp[b + i] |= a * 4096; + // gcc will always do it in ptr + (y * 32) order. + temp = (y * 32) + ptr; + temp[x + i] %= 0x1000; + temp[x + i] |= flags * 0x1000; - temp[b + i + 32] %= 0x1000; - temp[b + i + 32] |= a * 4096; + temp[x + i + 32] %= 0x1000; + temp[x + i + 32] |= flags * 0x1000; } } #else __attribute__((naked)) -void sub_80C1D98(u8 a, u8 b, u8 c, u8 d) +void SetSearchRectHighlight(u8 flags, u8 x, u8 y, u8 width) { asm(".syntax unified\n\ push {r4-r7,lr}\n\ @@ -5319,158 +5313,171 @@ _080C1DEC:\n\ } #endif -void sub_80C1DFC(u8 a, u8 b, u8 c) -{ - u8 r5 = (b & 1) | ((c & 1) << 1); +#define SEARCH_BG_SEARCH SEARCH_TOPBAR_SEARCH +#define SEARCH_BG_SHIFT SEARCH_TOPBAR_SHIFT +#define SEARCH_BG_CANCEL SEARCH_TOPBAR_CANCEL +#define SEARCH_BG_NAME (SEARCH_NAME + SEARCH_TOPBAR_COUNT) +#define SEARCH_BG_COLOR (SEARCH_COLOR + SEARCH_TOPBAR_COUNT) +#define SEARCH_BG_TYPE_SELECTION_LEFT (SEARCH_TYPE_LEFT + SEARCH_TOPBAR_COUNT) +#define SEARCH_BG_TYPE_SELECTION_RIGHT (SEARCH_TYPE_RIGHT + SEARCH_TOPBAR_COUNT) +#define SEARCH_BG_ORDER (SEARCH_ORDER + SEARCH_TOPBAR_COUNT) +#define SEARCH_BG_MODE (SEARCH_MODE + SEARCH_TOPBAR_COUNT) +#define SEARCH_BG_OK (SEARCH_OK + SEARCH_TOPBAR_COUNT) +#define SEARCH_BG_TYPE_TITLE (SEARCH_COUNT + SEARCH_TOPBAR_COUNT) - switch (a) +static void DrawSearchMenuItemBgHighlight(u8 searchBg, bool8 unselected, bool8 disabled) +{ + u8 highlightFlags = (unselected & 1) | ((disabled & 1) << 1); + + switch (searchBg) { - case 0: - case 1: - case 2: - sub_80C1D98(r5, gUnknown_0856ED30[a].unk4, gUnknown_0856ED30[a].unk5, gUnknown_0856ED30[a].unk6); - break; - case 3: - case 4: - case 7: - case 8: - sub_80C1D98(r5, gUnknown_0856ED48[a - 3].unk4, gUnknown_0856ED48[a - 3].unk5, gUnknown_0856ED48[a - 3].unk6); - // fall through - case 5: - case 6: - sub_80C1D98(r5, gUnknown_0856ED48[a - 3].unk7, gUnknown_0856ED48[a - 3].unk8, gUnknown_0856ED48[a - 3].unk9); - break; - case 10: - sub_80C1D98(r5, gUnknown_0856ED48[2].unk4, gUnknown_0856ED48[2].unk5, gUnknown_0856ED48[2].unk6); - break; - case 9: - if (!IsNationalPokedexEnabled()) - sub_80C1D98(r5, gUnknown_0856ED48[a - 3].unk4, gUnknown_0856ED48[a - 3].unk5 - 2, gUnknown_0856ED48[a - 3].unk6); - else - sub_80C1D98(r5, gUnknown_0856ED48[a - 3].unk4, gUnknown_0856ED48[a - 3].unk5, gUnknown_0856ED48[a - 3].unk6); - break; + case SEARCH_BG_SEARCH: + case SEARCH_BG_SHIFT: + case SEARCH_BG_CANCEL: + SetSearchRectHighlight(highlightFlags, sSearchMenuTopBarItems[searchBg].highlightX, sSearchMenuTopBarItems[searchBg].highlightY, sSearchMenuTopBarItems[searchBg].highlightWidth); + break; + case SEARCH_BG_NAME: + case SEARCH_BG_COLOR: + case SEARCH_BG_ORDER: + case SEARCH_BG_MODE: + SetSearchRectHighlight(highlightFlags, sSearchMenuItems[searchBg - SEARCH_TOPBAR_COUNT].titleBgX, sSearchMenuItems[searchBg - SEARCH_TOPBAR_COUNT].titleBgY, sSearchMenuItems[searchBg - SEARCH_TOPBAR_COUNT].titleBgWidth); + // fall through, draw selectionBg for above + case SEARCH_BG_TYPE_SELECTION_LEFT: + case SEARCH_BG_TYPE_SELECTION_RIGHT: + SetSearchRectHighlight(highlightFlags, sSearchMenuItems[searchBg - SEARCH_TOPBAR_COUNT].selectionBgX, sSearchMenuItems[searchBg - SEARCH_TOPBAR_COUNT].selectionBgY, sSearchMenuItems[searchBg - SEARCH_TOPBAR_COUNT].selectionBgWidth); + break; + case SEARCH_BG_TYPE_TITLE: + SetSearchRectHighlight(highlightFlags, sSearchMenuItems[SEARCH_TYPE_LEFT].titleBgX, sSearchMenuItems[SEARCH_TYPE_LEFT].titleBgY, sSearchMenuItems[SEARCH_TYPE_LEFT].titleBgWidth); + break; + case SEARCH_BG_OK: + if (!IsNationalPokedexEnabled()) + SetSearchRectHighlight(highlightFlags, sSearchMenuItems[searchBg - SEARCH_TOPBAR_COUNT].titleBgX, sSearchMenuItems[searchBg - SEARCH_TOPBAR_COUNT].titleBgY - 2, sSearchMenuItems[searchBg - SEARCH_TOPBAR_COUNT].titleBgWidth); + else + SetSearchRectHighlight(highlightFlags, sSearchMenuItems[searchBg - SEARCH_TOPBAR_COUNT].titleBgX, sSearchMenuItems[searchBg - SEARCH_TOPBAR_COUNT].titleBgY, sSearchMenuItems[searchBg - SEARCH_TOPBAR_COUNT].titleBgWidth); + break; } } -void sub_80C1EF4(u8 a) +static void SetInitialSearchMenuBgHighlights(u8 topBarItem) { - switch (a) + switch (topBarItem) { - case 0: - sub_80C1DFC(0, 0, 0); - sub_80C1DFC(1, 1, 0); - sub_80C1DFC(2, 1, 0); - sub_80C1DFC(3, 1, 0); - sub_80C1DFC(4, 1, 0); - sub_80C1DFC(10, 1, 0); - sub_80C1DFC(5, 1, 0); - sub_80C1DFC(6, 1, 0); - sub_80C1DFC(7, 1, 0); - sub_80C1DFC(8, 1, 0); - sub_80C1DFC(9, 1, 0); - break; - case 1: - sub_80C1DFC(0, 1, 0); - sub_80C1DFC(1, 0, 0); - sub_80C1DFC(2, 1, 0); - sub_80C1DFC(3, 1, 1); - sub_80C1DFC(4, 1, 1); - sub_80C1DFC(10, 1, 1); - sub_80C1DFC(5, 1, 1); - sub_80C1DFC(6, 1, 1); - sub_80C1DFC(7, 1, 0); - sub_80C1DFC(8, 1, 0); - sub_80C1DFC(9, 1, 0); - break; - case 2: - sub_80C1DFC(0, 1, 0); - sub_80C1DFC(1, 1, 0); - sub_80C1DFC(2, 0, 0); - sub_80C1DFC(3, 1, 1); - sub_80C1DFC(4, 1, 1); - sub_80C1DFC(10, 1, 1); - sub_80C1DFC(5, 1, 1); - sub_80C1DFC(6, 1, 1); - sub_80C1DFC(7, 1, 1); - sub_80C1DFC(8, 1, 1); - sub_80C1DFC(9, 1, 1); - break; + case SEARCH_TOPBAR_SEARCH: + DrawSearchMenuItemBgHighlight(SEARCH_BG_SEARCH, FALSE, FALSE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_SHIFT, TRUE, FALSE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_CANCEL, TRUE, FALSE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_NAME, TRUE, FALSE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_COLOR, TRUE, FALSE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_TYPE_TITLE, TRUE, FALSE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_TYPE_SELECTION_LEFT, TRUE, FALSE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_TYPE_SELECTION_RIGHT, TRUE, FALSE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_ORDER, TRUE, FALSE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_MODE, TRUE, FALSE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_OK, TRUE, FALSE); + break; + case SEARCH_TOPBAR_SHIFT: + DrawSearchMenuItemBgHighlight(SEARCH_BG_SEARCH, TRUE, FALSE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_SHIFT, FALSE, FALSE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_CANCEL, TRUE, FALSE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_NAME, TRUE, TRUE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_COLOR, TRUE, TRUE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_TYPE_TITLE, TRUE, TRUE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_TYPE_SELECTION_LEFT, TRUE, TRUE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_TYPE_SELECTION_RIGHT, TRUE, TRUE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_ORDER, TRUE, FALSE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_MODE, TRUE, FALSE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_OK, TRUE, FALSE); + break; + case SEARCH_TOPBAR_CANCEL: + DrawSearchMenuItemBgHighlight(SEARCH_BG_SEARCH, TRUE, FALSE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_SHIFT, TRUE, FALSE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_CANCEL, FALSE, FALSE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_NAME, TRUE, TRUE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_COLOR, TRUE, TRUE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_TYPE_TITLE, TRUE, TRUE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_TYPE_SELECTION_LEFT, TRUE, TRUE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_TYPE_SELECTION_RIGHT, TRUE, TRUE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_ORDER, TRUE, TRUE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_MODE, TRUE, TRUE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_OK, TRUE, TRUE); + break; } } -void sub_80C2040(u8 a) +static void HighlightSelectedSearchTopBarItem(u8 topBarItem) { - sub_80C1EF4(a); - sub_80C2618(gUnknown_0856ED30[a].text); + SetInitialSearchMenuBgHighlights(topBarItem); + EraseAndPrintSearchTextBox(sSearchMenuTopBarItems[topBarItem].description); } -void sub_80C2064(u8 a, u8 b) +static void HighlightSelectedSearchMenuItem(u8 topBarItem, u8 menuItem) { - sub_80C1EF4(a); - switch (b) + SetInitialSearchMenuBgHighlights(topBarItem); + switch (menuItem) { - case 0: - sub_80C1DFC(3, 0, 0); - break; - case 1: - sub_80C1DFC(4, 0, 0); - break; - case 2: - sub_80C1DFC(10, 0, 0); - sub_80C1DFC(5, 0, 0); - break; - case 3: - sub_80C1DFC(10, 0, 0); - sub_80C1DFC(6, 0, 0); - break; - case 4: - sub_80C1DFC(7, 0, 0); - break; - case 5: - sub_80C1DFC(8, 0, 0); - break; - case 6: - sub_80C1DFC(9, 0, 0); - break; + case SEARCH_NAME: + DrawSearchMenuItemBgHighlight(SEARCH_BG_NAME, FALSE, FALSE); + break; + case SEARCH_COLOR: + DrawSearchMenuItemBgHighlight(SEARCH_BG_COLOR, FALSE, FALSE); + break; + case SEARCH_TYPE_LEFT: + DrawSearchMenuItemBgHighlight(SEARCH_BG_TYPE_TITLE, FALSE, FALSE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_TYPE_SELECTION_LEFT, FALSE, FALSE); + break; + case SEARCH_TYPE_RIGHT: + DrawSearchMenuItemBgHighlight(SEARCH_BG_TYPE_TITLE, FALSE, FALSE); + DrawSearchMenuItemBgHighlight(SEARCH_BG_TYPE_SELECTION_RIGHT, FALSE, FALSE); + break; + case SEARCH_ORDER: + DrawSearchMenuItemBgHighlight(SEARCH_BG_ORDER, FALSE, FALSE); + break; + case SEARCH_MODE: + DrawSearchMenuItemBgHighlight(SEARCH_BG_MODE, FALSE, FALSE); + break; + case SEARCH_OK: + DrawSearchMenuItemBgHighlight(SEARCH_BG_OK, FALSE, FALSE); + break; } - sub_80C2618(gUnknown_0856ED48[b].text); + EraseAndPrintSearchTextBox(sSearchMenuItems[menuItem].description); } -void sub_80C20F8(u8 taskId) +// Prints the currently selected search parameters in the search menu selection boxes +static void PrintSelectedSearchParameters(u8 taskId) { - u16 var; + u16 searchParamId; - sub_80C12B0(0x28, 0x10, 0x60, 0x50); + ClearSearchMenuRect(40, 16, 96, 80); - var = gTasks[taskId].data[6] + gTasks[taskId].data[7]; - sub_80C1270(gDexSearchAlphaOptions[var].title, 0x2D, 0x11); + searchParamId = gTasks[taskId].tCursorPos_Name + gTasks[taskId].tScrollOffset_Name; + PrintSearchText(sDexSearchNameOptions[searchParamId].title, 0x2D, 0x11); - var = gTasks[taskId].data[8] + gTasks[taskId].data[9]; - sub_80C1270(gDexSearchColorOptions[var].title, 0x2D, 0x21); + searchParamId = gTasks[taskId].tCursorPos_Color + gTasks[taskId].tScrollOffset_Color; + PrintSearchText(sDexSearchColorOptions[searchParamId].title, 0x2D, 0x21); - var = gTasks[taskId].data[10] + gTasks[taskId].data[11]; - sub_80C1270(gDexSearchTypeOptions[var].title, 0x2D, 0x31); + searchParamId = gTasks[taskId].tCursorPos_TypeLeft + gTasks[taskId].tScrollOffset_TypeLeft; + PrintSearchText(sDexSearchTypeOptions[searchParamId].title, 0x2D, 0x31); - var = gTasks[taskId].data[12] + gTasks[taskId].data[13]; - sub_80C1270(gDexSearchTypeOptions[var].title, 0x5D, 0x31); + searchParamId = gTasks[taskId].tCursorPos_TypeRight + gTasks[taskId].tScrollOffset_TypeRight; + PrintSearchText(sDexSearchTypeOptions[searchParamId].title, 0x5D, 0x31); - var = gTasks[taskId].data[4] + gTasks[taskId].data[5]; - sub_80C1270(gDexSortOptions[var].title, 0x2D, 0x41); + searchParamId = gTasks[taskId].tCursorPos_Order + gTasks[taskId].tScrollOffset_Order; + PrintSearchText(sDexOrderOptions[searchParamId].title, 0x2D, 0x41); if (IsNationalPokedexEnabled()) { - var = gTasks[taskId].data[2] + gTasks[taskId].data[3]; - sub_80C1270(gDexModeOptions[var].title, 0x2D, 0x51); + searchParamId = gTasks[taskId].tCursorPos_Mode + gTasks[taskId].tScrollOffset_Mode; + PrintSearchText(sDexModeOptions[searchParamId].title, 0x2D, 0x51); } } -void sub_80C21D4(u8 a) +static void DrawOrEraseSearchParameterBox(bool8 erase) { u16 i; u16 j; u16* ptr = GetBgTilemapBuffer(3); - if (a == 0) + if (!erase) { *(ptr + 0x11) = 0xC0B; for (i = 0x12; i < 0x1F; i++) @@ -5497,136 +5504,142 @@ void sub_80C21D4(u8 a) } } -void sub_80C2294(u8 taskId) +// Prints the currently viewable search parameter titles in the right-hand text box +// and the currently selected search parameter description in the bottom text box +static void PrintSearchParameterText(u8 taskId) { - const struct PokedexOption *r6 = sSearchOptions[gTasks[taskId].data[1]].pokedexList; - const u16 *r8 = &gTasks[taskId].data[sSearchOptions[gTasks[taskId].data[1]].unk4]; - const u16 *r7 = &gTasks[taskId].data[sSearchOptions[gTasks[taskId].data[1]].unk5]; + const struct SearchOptionText *texts = sSearchOptions[gTasks[taskId].tMenuItem].texts; + const u16 *cursorPos = &gTasks[taskId].data[sSearchOptions[gTasks[taskId].tMenuItem].taskDataCursorPos]; + const u16 *scrollOffset = &gTasks[taskId].data[sSearchOptions[gTasks[taskId].tMenuItem].taskDataScrollOffset]; u16 i; u16 j; - sub_80C267C(); - for (i = 0, j = *r7; i < 6 && r6[j].title != NULL; i++, j++) - sub_80C2668(i, r6[j].title); - sub_80C2618(r6[*r8 + *r7].description); + ClearSearchParameterBoxText(); + + for (i = 0, j = *scrollOffset; i < MAX_SEARCH_PARAM_ON_SCREEN && texts[j].title != NULL; i++, j++) + PrintSearchParameterTitle(i, texts[j].title); + + EraseAndPrintSearchTextBox(texts[*cursorPos + *scrollOffset].description); } static u8 GetSearchModeSelection(u8 taskId, u8 option) { - const u16 *ptr1 = &gTasks[taskId].data[sSearchOptions[option].unk4]; - const u16 *ptr2 = &gTasks[taskId].data[sSearchOptions[option].unk5]; - u16 type = *ptr1 + *ptr2; + const u16 *cursorPos = &gTasks[taskId].data[sSearchOptions[option].taskDataCursorPos]; + const u16 *scrollOffset = &gTasks[taskId].data[sSearchOptions[option].taskDataScrollOffset]; + u16 id = *cursorPos + *scrollOffset; switch (option) { - default: - return 0; - case SEARCH_DEX_MODE: - return sPokedexModes[type]; - case SEARCH_ORDER: - return sSortOptions[type]; - case SEARCH_NAME: - if (type == 0) - return 0xFF; - else - return type; - case SEARCH_COLOR: - if (type == 0) - return 0xFF; - else - return type - 1; - case SEARCH_TYPE_1: - case SEARCH_TYPE_2: - return gDexSearchTypeIds[type]; + default: + return 0; + case SEARCH_MODE: + return sPokedexModes[id]; + case SEARCH_ORDER: + return sOrderOptions[id]; + case SEARCH_NAME: + if (id == 0) + return 0xFF; + else + return id; + case SEARCH_COLOR: + if (id == 0) + return 0xFF; + else + return id - 1; + case SEARCH_TYPE_LEFT: + case SEARCH_TYPE_RIGHT: + return sDexSearchTypeIds[id]; } } -void sub_80C23B8(u8 taskId) +static void SetDefaultSearchModeAndOrder(u8 taskId) { - u16 r3; + u16 selected; - switch (sPokedexView->unk614) + switch (sPokedexView->dexModeBackup) { - default: - case 0: - r3 = 0; - break; - case 1: - r3 = 1; - break; + default: + case DEX_MODE_HOENN: + selected = DEX_MODE_HOENN; + break; + case DEX_MODE_NATIONAL: + selected = DEX_MODE_NATIONAL; + break; } - gTasks[taskId].data[2] = r3; + gTasks[taskId].tCursorPos_Mode = selected; - switch (sPokedexView->unk618) + switch (sPokedexView->dexOrderBackup) { - default: - case 0: - r3 = 0; - break; - case 1: - r3 = 1; - break; - case 2: - r3 = 2; - break; - case 3: - r3 = 3; - break; - case 4: - r3 = 4; - break; - case 5: - r3 = 5; - break; + default: + case ORDER_NUMERICAL: + selected = ORDER_NUMERICAL; + break; + case ORDER_ALPHABETICAL: + selected = ORDER_ALPHABETICAL; + break; + case ORDER_HEAVIEST: + selected = ORDER_HEAVIEST; + break; + case ORDER_LIGHTEST: + selected = ORDER_LIGHTEST; + break; + case ORDER_TALLEST: + selected = ORDER_TALLEST; + break; + case ORDER_SMALLEST: + selected = ORDER_SMALLEST; + break; } - gTasks[taskId].data[4] = r3; + gTasks[taskId].tCursorPos_Order = selected; } -bool8 sub_80C244C(u8 taskId) +static bool8 SearchParamCantScrollUp(u8 taskId) { - u8 val1 = gTasks[taskId].data[1]; - const u16 *ptr = &gTasks[taskId].data[sSearchOptions[val1].unk5]; - u16 val2 = sSearchOptions[val1].numOptions - 1; + u8 menuItem = gTasks[taskId].tMenuItem; + const u16 *scrollOffset = &gTasks[taskId].data[sSearchOptions[menuItem].taskDataScrollOffset]; + u16 lastOption = sSearchOptions[menuItem].numOptions - 1; - if (val2 > 5 && *ptr != 0) + if (lastOption > MAX_SEARCH_PARAM_CURSOR_POS && *scrollOffset != 0) return FALSE; else return TRUE; } -bool8 sub_80C2494(u8 taskId) +static bool8 SearchParamCantScrollDown(u8 taskId) { - u8 val1 = gTasks[taskId].data[1]; - const u16 *ptr = &gTasks[taskId].data[sSearchOptions[val1].unk5]; - u16 val2 = sSearchOptions[val1].numOptions - 1; + u8 menuItem = gTasks[taskId].tMenuItem; + const u16 *scrollOffset = &gTasks[taskId].data[sSearchOptions[menuItem].taskDataScrollOffset]; + u16 lastOption = sSearchOptions[menuItem].numOptions - 1; - if (val2 > 5 && *ptr < val2 - 5) + if (lastOption > MAX_SEARCH_PARAM_CURSOR_POS && *scrollOffset < lastOption - MAX_SEARCH_PARAM_CURSOR_POS) return FALSE; else return TRUE; } -void sub_80C24E0(struct Sprite *sprite) +#define sTaskId data[0] + +static void SpriteCB_SearchParameterScrollArrow(struct Sprite *sprite) { - if (gTasks[sprite->data[0]].func == sub_80C1BCC) + if (gTasks[sprite->sTaskId].func == Task_HandleSearchParameterInput) { u8 val; - if (sprite->data[1] != 0) + if (sprite->sIsDownArrow) { - if (sub_80C2494(sprite->data[0])) + if (SearchParamCantScrollDown(sprite->sTaskId)) sprite->invisible = TRUE; else sprite->invisible = FALSE; } else { - if (sub_80C244C(sprite->data[0])) + if (SearchParamCantScrollUp(sprite->sTaskId)) sprite->invisible = TRUE; else sprite->invisible = FALSE; } - val = sprite->data[2] + sprite->data[1] * 128; + val = sprite->data[2] + sprite->sIsDownArrow * 128; sprite->pos2.y = gSineTable[val] / 128; sprite->data[2] += 8; } @@ -5636,44 +5649,47 @@ void sub_80C24E0(struct Sprite *sprite) } } -void sub_80C2594(u8 taskId) +static void CreateSearchParameterScrollArrows(u8 taskId) { u8 spriteId; - spriteId = CreateSprite(&sArrowSpriteTemplate, 184, 4, 0); - gSprites[spriteId].data[0] = taskId; - gSprites[spriteId].data[1] = 0; - gSprites[spriteId].callback = sub_80C24E0; + spriteId = CreateSprite(&sScrollArrowSpriteTemplate, 184, 4, 0); + gSprites[spriteId].sTaskId = taskId; + gSprites[spriteId].sIsDownArrow = FALSE; + gSprites[spriteId].callback = SpriteCB_SearchParameterScrollArrow; - spriteId = CreateSprite(&sArrowSpriteTemplate, 184, 108, 0); - gSprites[spriteId].data[0] = taskId; - gSprites[spriteId].data[1] = 1; + spriteId = CreateSprite(&sScrollArrowSpriteTemplate, 184, 108, 0); + gSprites[spriteId].sTaskId = taskId; + gSprites[spriteId].sIsDownArrow = TRUE; gSprites[spriteId].vFlip = TRUE; - gSprites[spriteId].callback = sub_80C24E0; + gSprites[spriteId].callback = SpriteCB_SearchParameterScrollArrow; } -void sub_80C2618(const u8* str) +#undef sTaskId +#undef sIsDownArrow + +static void EraseAndPrintSearchTextBox(const u8* str) { - sub_80C12B0(8, 0x78, 0xE0, 0x20); - sub_80C1270(str, 8, 0x79); + ClearSearchMenuRect(8, 120, 224, 32); + PrintSearchText(str, 8, 121); } -void sub_80C2638(u32 y) +static void EraseSelectorArrow(u32 y) { - sub_80C12B0(0x90, y * 16 + 8, 8, 16); + ClearSearchMenuRect(144, y * 16 + 8, 8, 16); } -void sub_80C2650(u32 left) +static void PrintSelectorArrow(u32 y) { - sub_80C1270(gText_SelectorArrow, 0x90, left * 16 + 9); + PrintSearchText(gText_SelectorArrow, 144, y * 16 + 9); } -void sub_80C2668(u32 left, const u8* str) +static void PrintSearchParameterTitle(u32 y, const u8* str) { - sub_80C1270(str, 0x98, left * 16 + 9); + PrintSearchText(str, 152, y * 16 + 9); } -void sub_80C267C(void) +static void ClearSearchParameterBoxText(void) { - sub_80C12B0(0x90, 8, 0x60, 0x60); + ClearSearchMenuRect(144, 8, 96, 96); } 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..ed692d6e3 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" @@ -66,7 +66,7 @@ struct PokeDexAreaScreen /*0x6E0*/ u16 numAreaMarkerSprites; /*0x6E2*/ u16 unk6E2; /*0x6E4*/ u16 unk6E4; - /*0x6E8*/ u8 *errno; + /*0x6E8*/ u8 *screenSwitchState; /*0x6EC*/ struct RegionMap regionMap; /*0xF70*/ u8 charBuffer[0x40]; /*0xFB0*/ struct Sprite * areaUnknownSprites[3]; @@ -83,11 +83,11 @@ static u16 GetRegionMapSectionId(u8, u8); static bool8 MapHasMon(const struct WildPokemonHeader *, u16); static bool8 MonListHasMon(const struct WildPokemonInfo *, u16, u16); static void DoAreaGlow(void); -static void Task_PokedexAreaScreen_0(u8); +static void Task_ShowPokedexAreaScreen(u8); static void CreateAreaMarkerSprites(void); static void LoadAreaUnknownGraphics(void); static void CreateAreaUnknownSprites(void); -static void Task_PokedexAreaScreen_1(u8); +static void Task_HandlePokedexAreaScreenInput(u8); static void sub_813D6B4(void); static void DestroyAreaMarkerSprites(void); @@ -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++; @@ -637,21 +637,23 @@ static void DoAreaGlow(void) } } -void ShowPokedexAreaScreen(u16 species, u8 *errno) +#define tState data[0] + +void ShowPokedexAreaScreen(u16 species, u8 *screenSwitchState) { u8 taskId; sPokedexAreaScreen = AllocZeroed(sizeof(*sPokedexAreaScreen)); sPokedexAreaScreen->species = species; - sPokedexAreaScreen->errno = errno; - errno[0] = 0; - taskId = CreateTask(Task_PokedexAreaScreen_0, 0); - gTasks[taskId].data[0] = 0; + sPokedexAreaScreen->screenSwitchState = screenSwitchState; + screenSwitchState[0] = 0; + taskId = CreateTask(Task_ShowPokedexAreaScreen, 0); + gTasks[taskId].tState = 0; } -static void Task_PokedexAreaScreen_0(u8 taskId) +static void Task_ShowPokedexAreaScreen(u8 taskId) { - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 0: ResetSpriteData(); @@ -662,13 +664,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 +680,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; @@ -702,21 +704,21 @@ static void Task_PokedexAreaScreen_0(u8 taskId) SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON); break; case 11: - gTasks[taskId].func = Task_PokedexAreaScreen_1; - gTasks[taskId].data[0] = 0; + gTasks[taskId].func = Task_HandlePokedexAreaScreenInput; + gTasks[taskId].tState = 0; return; } - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } -static void Task_PokedexAreaScreen_1(u8 taskId) +static void Task_HandlePokedexAreaScreenInput(u8 taskId) { DoAreaGlow(); - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { default: - gTasks[taskId].data[0] = 0; + gTasks[taskId].tState = 0; // fall through case 0: if (gPaletteFade.active) @@ -737,21 +739,21 @@ static void Task_PokedexAreaScreen_1(u8 taskId) return; break; case 2: - BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 16, RGB(0, 0, 0)); + BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 16, RGB_BLACK); break; case 3: if (gPaletteFade.active) return; DestroyAreaMarkerSprites(); - sPokedexAreaScreen->errno[0] = gTasks[taskId].data[1]; + sPokedexAreaScreen->screenSwitchState[0] = gTasks[taskId].data[1]; sub_813D6B4(); DestroyTask(taskId); - sub_81C4EB4(); + FreePokedexAreaMapBgNum(); FREE_AND_SET_NULL(sPokedexAreaScreen); return; } - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } static void sub_813D6B4(void) diff --git a/src/pokedex_cry_screen.c b/src/pokedex_cry_screen.c index 0b35b00ee..0a6f639ae 100644 --- a/src/pokedex_cry_screen.c +++ b/src/pokedex_cry_screen.c @@ -9,35 +9,53 @@ #include "trig.h" #include "window.h" -struct PokedexCryVolumeMeter { - s8 unk0; - s8 unk1; - u8 unk2; - u16 needleSpriteId; +// Cry meter needle positions +// +// 0 +// 32 . . -32 +// . . +// 64 . . -64 +// . . +// . . +// 96 . . -96 +// 127 +// +#define MIN_NEEDLE_POS 32 +#define MAX_NEEDLE_POS -32 + +#define NEEDLE_MOVE_INCREMENT 5 + +#define WAVEFORM_WINDOW_HEIGHT 56 + +struct PokedexCryMeterNeedle { + s8 rotation; + s8 targetRotation; + u8 moveIncrement; + u16 spriteId; }; struct PokedexCryScreen { - u8 unk0[16]; - u8 unk10; - u8 unk11; - u8 unk12; - u16 unk14; - u8 unk16; + u8 cryWaveformBuffer[16]; + u8 cryState; + u8 playhead; + u8 waveformPreviousY; + u16 unk; // Never read + u8 playStartPos; u16 species; - u8 unk1A; - u8 unk1B; + u8 cryOverrideCountdown; + u8 cryRepeatDelay; }; -static void sub_8145588(u16); -static void sub_81455A8(void); -static void sub_814560C(void); -static void sub_8145648(u8); -static void sub_81456A8(u8, u8); -static void sub_8145814(u8); -static void sub_8145824(u8, s16, u8); -static void sub_814596C(struct Sprite *); -static void sub_8145B24(s8); +static void PlayCryScreenCry(u16); +static void BufferCryWaveformSegment(void); +static void DrawWaveformFlatline(void); +static void AdvancePlayhead(u8); +static void DrawWaveformSegment(u8, u8); +static void DrawWaveformWindow(u8); +static void ShiftWaveformOver(u8, s16, bool8); +static void SpriteCB_CryMeterNeedle(struct Sprite *); +static void SetCryMeterNeedleTarget(s8); // IWRAM common u8 gDexCryScreenState; @@ -45,16 +63,16 @@ u8 gDexCryScreenState; // EWRAM vars static EWRAM_DATA struct PokedexCryScreen *sDexCryScreen = NULL; static EWRAM_DATA u8 *sCryWaveformWindowTiledata = NULL; -static EWRAM_DATA struct PokedexCryVolumeMeter *sCryVolumeMeter = NULL; +static EWRAM_DATA struct PokedexCryMeterNeedle *sCryMeterNeedle = NULL; -const u16 CryMeterNeedlePalette[] = INCBIN_U16("graphics/pokedex/cry_meter_needle.gbapal"); -const u8 CryMeterNeedleTiles[] = INCBIN_U8("graphics/pokedex/cry_meter_needle.4bpp"); +static const u16 sCryMeterNeedle_Pal[] = INCBIN_U16("graphics/pokedex/cry_meter_needle.gbapal"); +static const u8 sCryMeterNeedle_Gfx[] = INCBIN_U8("graphics/pokedex/cry_meter_needle.4bpp"); -const u16 gUnknown_085B8378[] = INCBIN_U16("graphics/pokedex/cry_meter_map.bin"); -const u16 gUnknown_085B8418[] = INCBIN_U16("graphics/pokedex/cry_meter.gbapal"); -const u8 gUnknown_085B8438[] = INCBIN_U8("graphics/pokedex/cry_meter.4bpp.lz"); +static const u16 sCryMeter_Tilemap[] = INCBIN_U16("graphics/pokedex/cry_meter_map.bin"); // Unused +static const u16 sCryMeter_Pal[] = INCBIN_U16("graphics/pokedex/cry_meter.gbapal"); +static const u8 sCryMeter_Gfx[] = INCBIN_U8("graphics/pokedex/cry_meter.4bpp.lz"); -const u16 gUnknown_085B8770[][72] = +static const u16 sWaveformOffsets[][72] = { { 0x0000, 0x0004, 0x0008, 0x000C, 0x0010, 0x0014, 0x0018, 0x001C, @@ -139,33 +157,36 @@ const u16 gUnknown_085B8770[][72] = } }; -const u16 gUnknown_085B8BF0[] = INCBIN_U16("graphics/pokedex/85B8C10.gbapal"); -const u8 gUnknown_085B8C10[] = INCBIN_U8("graphics/pokedex/85B8C10.4bpp"); +static const u16 sCryScreenBg_Pal[] = INCBIN_U16("graphics/pokedex/cry_screen_bg.gbapal"); +static const u8 sCryScreenBg_Gfx[] = INCBIN_U8("graphics/pokedex/cry_screen_bg.4bpp"); -const u8 gUnknown_085B8C30[] = {0xF0, 0x0F}; -const u8 gUnknown_085B8C32[][16] = +static const u8 sWaveformTileDataNybbleMasks[] = {0xF0, 0x0F}; + +// Waveform is blue in the middle (8) grading to white at peaks (15) +// Split into two arrays for the two vertical slice halves +static const u8 sWaveformColor[][16] = { { - 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08, - 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F + 15, 14, 13, 12, 11, 10, 9, 8, + 8, 9, 10, 11, 12, 13, 14, 15, }, { - 0xF0, 0xE0, 0xD0, 0xC0, 0xB0, 0xA0, 0x90, 0x80, - 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0 + 15 << 4, 14 << 4, 13 << 4, 12 << 4, 11 << 4, 10 << 4, 9 << 4, 8 << 4, + 8 << 4, 9 << 4, 10 << 4, 11 << 4, 12 << 4, 13 << 4, 14 << 4, 15 << 4, } }; -const union AnimCmd gSpriteAnim_85B8C54[] = +static const union AnimCmd sSpriteAnim_CryMeterNeedle[] = { ANIMCMD_FRAME(0, 30), ANIMCMD_END }; -const union AnimCmd *const gSpriteAnimTable_85B8C5C[] = +static const union AnimCmd *const sSpriteAnimTable_CryMeterNeedle[] = { - gSpriteAnim_85B8C54 + sSpriteAnim_CryMeterNeedle }; -const struct OamData gOamData_85B8C60 = +static const struct OamData sOamData_CryMeterNeedle = { .y = 160, .affineMode = ST_OAM_AFFINE_NORMAL, @@ -179,33 +200,33 @@ const struct OamData gOamData_85B8C60 = .paletteNum = 0, }; -const struct SpriteTemplate gUnknown_085B8C68 = +static const struct SpriteTemplate sCryMeterNeedleSpriteTemplate = { - 0x2000, - 0x2000, - &gOamData_85B8C60, - gSpriteAnimTable_85B8C5C, - NULL, - gDummySpriteAffineAnimTable, - sub_814596C + .tileTag = 0x2000, + .paletteTag = 0x2000, + .oam = &sOamData_CryMeterNeedle, + .anims = sSpriteAnimTable_CryMeterNeedle, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCB_CryMeterNeedle }; -const struct SpriteSheet gCryMeterNeedleSpriteSheets[] = +static const struct SpriteSheet sCryMeterNeedleSpriteSheets[] = { - {CryMeterNeedleTiles, 0x800, 0x2000}, + {sCryMeterNeedle_Gfx, 0x800, 0x2000}, {} }; -const struct SpritePalette gCryMeterNeedleSpritePalettes[] = +static const struct SpritePalette sCryMeterNeedleSpritePalettes[] = { - {CryMeterNeedlePalette, 0x2000}, + {sCryMeterNeedle_Pal, 0x2000}, {} }; -bool8 sub_8145354(struct CryRelatedStruct *arg0, u8 windowId) +bool8 LoadCryWaveformWindow(struct CryScreenWindow *window, u8 windowId) { u8 i; - u8 retVal = FALSE; + u8 finished = FALSE; switch (gDexCryScreenState) { @@ -216,112 +237,119 @@ bool8 sub_8145354(struct CryRelatedStruct *arg0, u8 windowId) sCryWaveformWindowTiledata = (u8*)GetWindowAttribute(windowId, WINDOW_TILE_DATA); } - sDexCryScreen->unk14 = arg0->unk0; - sDexCryScreen->unk16 = arg0->yPos; - sDexCryScreen->unk1A = 0; - sDexCryScreen->unk1B = 0; - sDexCryScreen->unk10 = 0; - sDexCryScreen->unk12 = 28; - sDexCryScreen->unk11 = 0; - sub_8145824(windowId, -8 * arg0->xPos, 1); + sDexCryScreen->unk = window->unk0; + sDexCryScreen->playStartPos = window->yPos; + sDexCryScreen->cryOverrideCountdown = 0; + sDexCryScreen->cryRepeatDelay = 0; + sDexCryScreen->cryState = 0; + sDexCryScreen->waveformPreviousY = WAVEFORM_WINDOW_HEIGHT / 2; + sDexCryScreen->playhead = 0; + ShiftWaveformOver(windowId, -8 * window->xPos, TRUE); // Does nothing for (i = 0; i < 224; i++) - CopyToWindowPixelBuffer(windowId, gUnknown_085B8C10, TILE_SIZE_4BPP, i); + CopyToWindowPixelBuffer(windowId, sCryScreenBg_Gfx, TILE_SIZE_4BPP, i); gDexCryScreenState++; break; case 1: - for (i = 0; i < sDexCryScreen->unk16 * 8; i++) - sub_81456A8(i, 0); + for (i = 0; i < sDexCryScreen->playStartPos * 8; i++) + DrawWaveformSegment(i, 0); gDexCryScreenState++; break; case 2: - sub_8145814(windowId); - LoadPalette(gUnknown_085B8BF0, arg0->paletteNo * 16, 32); - retVal = TRUE; + DrawWaveformWindow(windowId); + LoadPalette(sCryScreenBg_Pal, window->paletteNo * 16, 32); + finished = TRUE; break; } - return retVal; + return finished; } -void sub_814545C(u8 windowId) +void UpdateCryWaveformWindow(u8 windowId) { - u8 var0; + u8 waveformIdx; - sub_8145814(windowId); - sub_8145648(windowId); - if (sDexCryScreen->unk1B) - sDexCryScreen->unk1B--; + DrawWaveformWindow(windowId); + AdvancePlayhead(windowId); - if (sDexCryScreen->unk1A) + // Cry cant be replayed until this counter is done + if (sDexCryScreen->cryRepeatDelay) + sDexCryScreen->cryRepeatDelay--; + + // Once a cry replay has started, it waits for this countdown before playing + if (sDexCryScreen->cryOverrideCountdown) { - sDexCryScreen->unk1A--; - if (!sDexCryScreen->unk1A) + sDexCryScreen->cryOverrideCountdown--; + if (!sDexCryScreen->cryOverrideCountdown) { - sub_8145588(sDexCryScreen->species); - sub_814560C(); + PlayCryScreenCry(sDexCryScreen->species); + DrawWaveformFlatline(); return; } } - if (sDexCryScreen->unk10 == 0) + // No cry playing + if (sDexCryScreen->cryState == 0) { - sub_814560C(); + DrawWaveformFlatline(); return; } - if (sDexCryScreen->unk10 == 1) + // Cry playing, buffer waveform + if (sDexCryScreen->cryState == 1) { - sub_81455A8(); + BufferCryWaveformSegment(); } - else if (sDexCryScreen->unk10 > 8) + else if (sDexCryScreen->cryState > 8) { + // Buffered waveform exhausted, end or buffer more if (!IsCryPlaying()) { - sub_814560C(); - sDexCryScreen->unk10 = 0; + DrawWaveformFlatline(); + sDexCryScreen->cryState = 0; return; } - sub_81455A8(); - sDexCryScreen->unk10 = 1; + BufferCryWaveformSegment(); + sDexCryScreen->cryState = 1; } - var0 = 2 * (sDexCryScreen->unk10 - 1); - sub_81456A8(sDexCryScreen->unk16 * 8 + sDexCryScreen->unk11 - 2, sDexCryScreen->unk0[var0]); - sub_81456A8(sDexCryScreen->unk16 * 8 + sDexCryScreen->unk11 - 1, sDexCryScreen->unk0[var0 + 1]); - sDexCryScreen->unk10++; + // Draw cry + waveformIdx = 2 * (sDexCryScreen->cryState - 1); + DrawWaveformSegment(sDexCryScreen->playStartPos * 8 + sDexCryScreen->playhead - 2, sDexCryScreen->cryWaveformBuffer[waveformIdx]); + DrawWaveformSegment(sDexCryScreen->playStartPos * 8 + sDexCryScreen->playhead - 1, sDexCryScreen->cryWaveformBuffer[waveformIdx + 1]); + sDexCryScreen->cryState++; } -void sub_8145534(u16 species) +void CryScreenPlayButton(u16 species) { - if (gMPlayInfo_BGM.status & MUSICPLAYER_STATUS_PAUSE && !sDexCryScreen->unk1A) + if (gMPlayInfo_BGM.status & MUSICPLAYER_STATUS_PAUSE && !sDexCryScreen->cryOverrideCountdown) { - if (!sDexCryScreen->unk1B) + if (!sDexCryScreen->cryRepeatDelay) { - sDexCryScreen->unk1B = 4; + sDexCryScreen->cryRepeatDelay = 4; if (IsCryPlaying() == TRUE) { StopCry(); sDexCryScreen->species = species; - sDexCryScreen->unk1A = 2; + sDexCryScreen->cryOverrideCountdown = 2; } else { - sub_8145588(species); + PlayCryScreenCry(species); } } } } -static void sub_8145588(u16 species) +static void PlayCryScreenCry(u16 species) { - PlayCry2(species, 0, 0x7d, 10); - sDexCryScreen->unk10 = 1; + PlayCry2(species, 0, 125, 10); + sDexCryScreen->cryState = 1; } -static void sub_81455A8(void) +static void BufferCryWaveformSegment(void) { u8 i; s8 *baseBuffer; @@ -333,197 +361,218 @@ static void sub_81455A8(void) baseBuffer = gSoundInfo.pcmBuffer + (gSoundInfo.pcmDmaPeriod + 1 - gPcmDmaCounter) * gSoundInfo.pcmSamplesPerVBlank; buffer = baseBuffer + 0x630; - for (i = 0; i < 16; i++) - sDexCryScreen->unk0[i] = buffer[i * 2] * 2; + for (i = 0; i < ARRAY_COUNT(sDexCryScreen->cryWaveformBuffer); i++) + sDexCryScreen->cryWaveformBuffer[i] = buffer[i * 2] * 2; } -static void sub_814560C(void) +static void DrawWaveformFlatline(void) { - sub_81456A8(sDexCryScreen->unk16 * 8 + sDexCryScreen->unk11 - 2, 0); - sub_81456A8(sDexCryScreen->unk16 * 8 + sDexCryScreen->unk11 - 1, 0); + DrawWaveformSegment(sDexCryScreen->playStartPos * 8 + sDexCryScreen->playhead - 2, 0); + DrawWaveformSegment(sDexCryScreen->playStartPos * 8 + sDexCryScreen->playhead - 1, 0); } -static void sub_8145648(u8 windowId) +static void AdvancePlayhead(u8 windowId) { u8 i; u16 offset; - sub_8145824(windowId, sDexCryScreen->unk11, 0); - sDexCryScreen->unk11 += 2; - offset = (sDexCryScreen->unk11 / 8 + sDexCryScreen->unk16 + 1) % 32; + ShiftWaveformOver(windowId, sDexCryScreen->playhead, FALSE); + sDexCryScreen->playhead += 2; + offset = (sDexCryScreen->playhead / 8 + sDexCryScreen->playStartPos + 1) % 32; for (i = 0; i < 7; i++) - CopyToWindowPixelBuffer(windowId, gUnknown_085B8C10, TILE_SIZE_4BPP, offset + (i * TILE_SIZE_4BPP)); + CopyToWindowPixelBuffer(windowId, sCryScreenBg_Gfx, TILE_SIZE_4BPP, offset + (i * TILE_SIZE_4BPP)); } -static void sub_81456A8(u8 a0, u8 a1) +// Waveform segments are drawn in alternate vertical slices +// Note that the waveform isnt put on screen until DrawWaveformWindow +static void DrawWaveformSegment(u8 position, u8 amplitude) { - u8 sp0; - u8 r6; - u8 r8; - u16 offset; - u16 r1; - u8 i; + // Position is a bitfield containing the play start pos, the playhead pos, and which vertical slice half to draw + #define PLAY_START_POS (position >> 3) + #define PLAYHEAD_POS (position & ((1 << 3) - 1)) + #define VERT_SLICE (position & 1) - r1 = (a1 + 127) * 256; - i = r1 / 1152.0; - if (i > 55) - i = 55; - sp0 = i; - r6 = a0 & 1; - if (i > sDexCryScreen->unk12) + u8 currentPointY; + u8 nybble; + u16 offset; + u16 temp; + u8 y; + + temp = (amplitude + 127) * 256; + y = temp / 1152.0; + if (y > WAVEFORM_WINDOW_HEIGHT - 1) + y = WAVEFORM_WINDOW_HEIGHT - 1; + currentPointY = y; + nybble = VERT_SLICE; + if (y > sDexCryScreen->waveformPreviousY) { + // Current point lower than previous point, draw point and draw line up to previous do { - offset = gUnknown_085B8770[a0 & 0x7][i] + (a0 / 8) * TILE_SIZE_4BPP; - sCryWaveformWindowTiledata[offset] &= gUnknown_085B8C30[r6]; - sCryWaveformWindowTiledata[offset] |= gUnknown_085B8C32[r6][((i / 3) - 1) & 0x0F]; - i--; - } while (i > sDexCryScreen->unk12); + offset = sWaveformOffsets[PLAYHEAD_POS][y] + PLAY_START_POS * TILE_SIZE_4BPP; + sCryWaveformWindowTiledata[offset] &= sWaveformTileDataNybbleMasks[nybble]; + sCryWaveformWindowTiledata[offset] |= sWaveformColor[nybble][((y / 3) - 1) & 0x0F]; + y--; + } while (y > sDexCryScreen->waveformPreviousY); } else { + // Current point higher than previous point, draw point and draw line down to previous do { - offset = gUnknown_085B8770[a0 & 0x7][i] + (a0 / 8) * TILE_SIZE_4BPP; - sCryWaveformWindowTiledata[offset] &= gUnknown_085B8C30[r6]; - sCryWaveformWindowTiledata[offset] |= gUnknown_085B8C32[r6][((i / 3) - 1) & 0x0F]; - i++; - } while (i < sDexCryScreen->unk12); + offset = sWaveformOffsets[PLAYHEAD_POS][y] + PLAY_START_POS * TILE_SIZE_4BPP; + sCryWaveformWindowTiledata[offset] &= sWaveformTileDataNybbleMasks[nybble]; + sCryWaveformWindowTiledata[offset] |= sWaveformColor[nybble][((y / 3) - 1) & 0x0F]; + y++; + } while (y < sDexCryScreen->waveformPreviousY); } - sDexCryScreen->unk12 = sp0; + sDexCryScreen->waveformPreviousY = currentPointY; } -static void sub_8145814(u8 windowId) +static void DrawWaveformWindow(u8 windowId) { CopyWindowToVram(windowId, 2); } -static void sub_8145824(u8 windowId, s16 arg1, u8 arg2) +// rsVertical is leftover from a very different version of this function in RS +// In RS, when TRUE it would use VOFS and when FALSE it would use HOFS (only FALSE was used) +// Here when TRUE it does nothing +static void ShiftWaveformOver(u8 windowId, s16 offset, bool8 rsVertical) { - if (!arg2) + if (!rsVertical) { u8 bg = GetWindowAttribute(windowId, WINDOW_BG); - ChangeBgX(bg, arg1 << 8, 0); + ChangeBgX(bg, offset << 8, 0); } } -bool8 sub_8145850(struct CryRelatedStruct *arg0, u8 windowId) +bool8 LoadCryMeter(struct CryScreenWindow *window, u8 windowId) { - int retVal = FALSE; + bool8 finished = FALSE; switch (gDexCryScreenState) { case 0: - if (!sCryVolumeMeter) - sCryVolumeMeter = AllocZeroed(sizeof(*sCryVolumeMeter)); + if (!sCryMeterNeedle) + sCryMeterNeedle = AllocZeroed(sizeof(*sCryMeterNeedle)); - CopyToWindowPixelBuffer(windowId, gUnknown_085B8438, 0, 0); - LoadPalette(gUnknown_085B8418, arg0->paletteNo * 16, 32); + CopyToWindowPixelBuffer(windowId, sCryMeter_Gfx, 0, 0); + LoadPalette(sCryMeter_Pal, window->paletteNo * 16, 32); gDexCryScreenState++; break; case 1: - LoadSpriteSheets(gCryMeterNeedleSpriteSheets); - LoadSpritePalettes(gCryMeterNeedleSpritePalettes); - sCryVolumeMeter->needleSpriteId = CreateSprite(&gUnknown_085B8C68, 40 + arg0->xPos * 8, 56 + arg0->yPos * 8, 1); - sCryVolumeMeter->unk0 = 0x20; - sCryVolumeMeter->unk1 = 0x20; - sCryVolumeMeter->unk2 = 0; - retVal = TRUE; + LoadSpriteSheets(sCryMeterNeedleSpriteSheets); + LoadSpritePalettes(sCryMeterNeedleSpritePalettes); + sCryMeterNeedle->spriteId = CreateSprite(&sCryMeterNeedleSpriteTemplate, 40 + window->xPos * 8, 56 + window->yPos * 8, 1); + sCryMeterNeedle->rotation = MIN_NEEDLE_POS; + sCryMeterNeedle->targetRotation = MIN_NEEDLE_POS; + sCryMeterNeedle->moveIncrement = 0; + finished = TRUE; break; } - return retVal; + return finished; } -void sub_8145914(void) +void FreeCryScreen(void) { - FreeSpritePaletteByTag(GetSpritePaletteTagByPaletteNum(gSprites[sCryVolumeMeter->needleSpriteId].oam.paletteNum)); - DestroySprite(gSprites + sCryVolumeMeter->needleSpriteId); + FreeSpritePaletteByTag(GetSpritePaletteTagByPaletteNum(gSprites[sCryMeterNeedle->spriteId].oam.paletteNum)); + DestroySprite(gSprites + sCryMeterNeedle->spriteId); FREE_AND_SET_NULL(sDexCryScreen); - FREE_AND_SET_NULL(sCryVolumeMeter); + FREE_AND_SET_NULL(sCryMeterNeedle); } -static void sub_814596C(struct Sprite *sprite) +static void SpriteCB_CryMeterNeedle(struct Sprite *sprite) { u16 i; - s8 r3; + s8 peakAmplitude; s16 x; s16 y; struct ObjAffineSrcData affine; struct OamMatrix matrix; - u8 *var0; + u8 amplitude; - gSprites[sCryVolumeMeter->needleSpriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; - gSprites[sCryVolumeMeter->needleSpriteId].oam.affineParam = 0; - switch (sDexCryScreen->unk10) - { - case 0: - sCryVolumeMeter->unk1 = 0x20; - if (sCryVolumeMeter->unk0 > 0) - { - if (sCryVolumeMeter->unk2 != 1) - sCryVolumeMeter->unk2--; - } - else - sCryVolumeMeter->unk2 = 5; - break; - case 2: - r3 = 0; - for (i = 0; i < 16; i++) - { - if (r3 < sDexCryScreen->unk0[i]) - r3 = sDexCryScreen->unk0[i]; - } - sub_8145B24(r3 * 0xd0 / 0x100); - break; - case 6: - var0 = &sDexCryScreen->unk0[10]; - sub_8145B24(*var0 * 0xd0 / 0x100); - break; - } + gSprites[sCryMeterNeedle->spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; + gSprites[sCryMeterNeedle->spriteId].oam.affineParam = 0; - if (sCryVolumeMeter->unk0 == sCryVolumeMeter->unk1) + // While no cry is playing, cryState is 0 + // While cry is playing, cryState loops 1-8 + switch (sDexCryScreen->cryState) { - // empty block - } - else if (sCryVolumeMeter->unk0 < sCryVolumeMeter->unk1) - { - sCryVolumeMeter->unk0 += sCryVolumeMeter->unk2; - if (sCryVolumeMeter->unk0 > sCryVolumeMeter->unk1) + case 0: + sCryMeterNeedle->targetRotation = MIN_NEEDLE_POS; + if (sCryMeterNeedle->rotation > 0) { - sCryVolumeMeter->unk0 = sCryVolumeMeter->unk1; - sCryVolumeMeter->unk1 = 0; + if (sCryMeterNeedle->moveIncrement != 1) + sCryMeterNeedle->moveIncrement--; + } + else + { + sCryMeterNeedle->moveIncrement = NEEDLE_MOVE_INCREMENT; + } + break; + case 2: + peakAmplitude = 0; + for (i = 0; i < ARRAY_COUNT(sDexCryScreen->cryWaveformBuffer); i++) + { + if (peakAmplitude < sDexCryScreen->cryWaveformBuffer[i]) + peakAmplitude = sDexCryScreen->cryWaveformBuffer[i]; + } + SetCryMeterNeedleTarget(peakAmplitude * 208 / 256); + break; + case 6: + // To introduce some randomness, needle jumps to set pos in waveform rather than peak + amplitude = sDexCryScreen->cryWaveformBuffer[10]; + SetCryMeterNeedleTarget(amplitude * 208 / 256); + break; + } + + if (sCryMeterNeedle->rotation == sCryMeterNeedle->targetRotation) + { + // Empty, needle has reached target + } + else if (sCryMeterNeedle->rotation < sCryMeterNeedle->targetRotation) + { + // Rotate needle left + sCryMeterNeedle->rotation += sCryMeterNeedle->moveIncrement; + if (sCryMeterNeedle->rotation > sCryMeterNeedle->targetRotation) + { + sCryMeterNeedle->rotation = sCryMeterNeedle->targetRotation; + sCryMeterNeedle->targetRotation = 0; } } else { - sCryVolumeMeter->unk0 -= sCryVolumeMeter->unk2; - if (sCryVolumeMeter->unk0 < sCryVolumeMeter->unk1) + // Rotate needle right + sCryMeterNeedle->rotation -= sCryMeterNeedle->moveIncrement; + if (sCryMeterNeedle->rotation < sCryMeterNeedle->targetRotation) { - sCryVolumeMeter->unk0 = sCryVolumeMeter->unk1; - sCryVolumeMeter->unk1 = 0; + sCryMeterNeedle->rotation = sCryMeterNeedle->targetRotation; + sCryMeterNeedle->targetRotation = 0; } } - affine.xScale = 0x100; - affine.yScale = 0x100; - affine.rotation = sCryVolumeMeter->unk0 * 256; + affine.xScale = 256; + affine.yScale = 256; + affine.rotation = sCryMeterNeedle->rotation * 256; ObjAffineSet(&affine, &matrix, 1, 2); SetOamMatrix(0, matrix.a, matrix.b, matrix.c, matrix.d); - x = gSineTable[((sCryVolumeMeter->unk0 + 0x7F) & 0xFF)]; - y = gSineTable[((sCryVolumeMeter->unk0 + 0x7F) & 0xFF) + 0x40]; + x = gSineTable[((sCryMeterNeedle->rotation + 0x7F) & 0xFF)]; + y = gSineTable[((sCryMeterNeedle->rotation + 0x7F) & 0xFF) + 64]; sprite->pos2.x = x * 24 / 256; sprite->pos2.y = y * 24 / 256; } -static void sub_8145B24(s8 a0) +static void SetCryMeterNeedleTarget(s8 offset) { - u16 r2 = (0x20 - a0) & 0xff; - if (r2 > 0x20 && r2 < 0xe0) - r2 = 0xe0; + u16 rotation = (MIN_NEEDLE_POS - offset) & 0xFF; - sCryVolumeMeter->unk1 = r2; - sCryVolumeMeter->unk2 = 5; + // Min is positive, max is negative. Make sure needle hasnt moved out of bounds + if (rotation > MIN_NEEDLE_POS && rotation < (u8)MAX_NEEDLE_POS) + rotation = (u8)MAX_NEEDLE_POS; + + sCryMeterNeedle->targetRotation = rotation; + sCryMeterNeedle->moveIncrement = NEEDLE_MOVE_INCREMENT; } diff --git a/src/pokemon.c b/src/pokemon.c index eb03ac720..c641568c6 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -4109,7 +4109,7 @@ u8 CalculatePlayerPartyCount(void) { gPlayerPartyCount = 0; - while (gPlayerPartyCount < 6 + while (gPlayerPartyCount < PARTY_SIZE && GetMonData(&gPlayerParty[gPlayerPartyCount], MON_DATA_SPECIES, NULL) != SPECIES_NONE) { gPlayerPartyCount++; @@ -4122,7 +4122,7 @@ u8 CalculateEnemyPartyCount(void) { gEnemyPartyCount = 0; - while (gEnemyPartyCount < 6 + while (gEnemyPartyCount < PARTY_SIZE && GetMonData(&gEnemyParty[gEnemyPartyCount], MON_DATA_SPECIES, NULL) != SPECIES_NONE) { gEnemyPartyCount++; @@ -4209,7 +4209,7 @@ void CreateSecretBaseEnemyParty(struct SecretBase *secretBaseRecord) SetMonData(&gEnemyParty[i], MON_DATA_HELD_ITEM, &gBattleResources->secretBase->party.heldItems[i]); - for (j = 0; j < 6; j++) + for (j = 0; j < NUM_STATS; j++) SetMonData(&gEnemyParty[i], MON_DATA_HP_EV + j, &gBattleResources->secretBase->party.EVs[i]); for (j = 0; j < MAX_MON_MOVES; j++) diff --git a/src/pokemon_jump.c b/src/pokemon_jump.c index 6c76b15a6..f2f416c35 100755 --- a/src/pokemon_jump.c +++ b/src/pokemon_jump.c @@ -12,9 +12,10 @@ #include "link_rfu.h" #include "main.h" #include "menu.h" +#include "minigame_countdown.h" #include "palette.h" #include "random.h" -#include "rom_8034C54.h" +#include "digit_obj_util.h" #include "save.h" #include "script.h" #include "sound.h" @@ -289,21 +290,8 @@ static void sub_802D5E4(void); static void sub_802D72C(void); static void sub_802D688(void); static void Task_ShowPokemonJumpRecords(u8 taskId); -static void sub_802E6D0(u8 taskId); -static void sub_802EB98(u8 taskId); static void sub_802E500(u16 windowId, int width); static void TruncateToFirstWordOnly(u8 *str); -static void sub_802EF50(u16 tileTag, u16 palTag); -static u8 sub_802EFA8(u16 tileTag, u16 palTag, s16 x, s16 y, u8 subpriority); -static void sub_802EFFC(u16 tileTag, u16 palTag, s16 x, s16 y, u8 subpriority, s16 *spriteId1, s16 *spriteId2); -static bool32 sub_802EC98(u8 spriteId); -static bool32 sub_802EE30(u8 spriteId); -static void sub_802EDCC(u8 spriteId1, u8 spriteId2, u8 spriteId3); -static void sub_802EE5C(struct Sprite *sprite); -static void sub_802E83C(u8 taskId); -static void sub_802E8C8(u8 taskId); -static void sub_802EA50(u8 taskId); -static void sub_802EAB0(u8 taskId); EWRAM_DATA static struct PokemonJump1 *gUnknown_02022CFC = NULL; EWRAM_DATA static struct PokemonJump2 *gUnknown_02022D00 = NULL; @@ -2807,13 +2795,13 @@ static void sub_802CF50(struct PokemonJump2 *arg0, int arg1) static void sub_802D044(struct PokemonJump2 *arg0) { - sub_802EB24(9, 7, 120, 80, 0); + StartMinigameCountdown(9, 7, 120, 80, 0); sub_802CD3C(arg0); } static bool32 sub_802D068(void) { - return sub_802EB84(); + return IsMinigameCountdownRunning(); } static void sub_802D074(struct PokemonJump2 *arg0) @@ -2831,7 +2819,7 @@ static void sub_802D074(struct PokemonJump2 *arg0) static void sub_802D0AC(void) { FreeAllWindowBuffers(); - sub_8034CC8(); + DigitObjUtil_Free(); } static void sub_802D0BC(struct PokemonJump2 *arg0) @@ -3515,37 +3503,37 @@ static int sub_802DCCC(u8 flags) static void sub_802DD08(void) { - struct UnkStruct3 unkStruct; - struct UnkStruct3 *ptr = &unkStruct; // This temp variable is needed to match, don't ask me why. + struct DigitObjUtilTemplate template; + struct DigitObjUtilTemplate *ptr = &template; // This temp variable is needed to match, don't ask me why. ptr->shape = SPRITE_SHAPE(8x8); ptr->size = SPRITE_SIZE(8x8); - ptr->field_0_0 = 0; + ptr->strConvMode = 0; ptr->priority = 1; - ptr->field_1 = 5; + ptr->oamCount = 5; ptr->xDelta = 8; ptr->x = 108; ptr->y = 6; ptr->spriteSheet = (void*) &gUnknown_082FE1EC; ptr->spritePal = &gUnknown_082FE1F4; - sub_8034C54(2); - sub_8034D14(0, 0, ptr); + DigitObjUtil_Init(2); + DigitObjUtil_CreatePrinter(0, 0, ptr); - unkStruct.field_1 = 4; - unkStruct.x = 30; - unkStruct.y = 6; - sub_8034D14(1, 0, &unkStruct); + template.oamCount = 4; + template.x = 30; + template.y = 6; + DigitObjUtil_CreatePrinter(1, 0, &template); } static void sub_802DD64(int arg0) { - sub_8035044(0, arg0); + DigitObjUtil_PrintNumOn(0, arg0); } static void sub_802DD74(u16 arg0) { - sub_8035044(1, arg0); + DigitObjUtil_PrintNumOn(1, arg0); } static void sub_802DD88(u8 multiplayerId) @@ -3987,611 +3975,3 @@ static void TruncateToFirstWordOnly(u8 *str) } } } - -static const u16 gPkmnJump321StartPal1[] = INCBIN_U16("graphics/link_games/pkmnjump_321start1.gbapal"); -static const u32 gPkmnJump321StartGfx1[] = INCBIN_U32("graphics/link_games/pkmnjump_321start1.4bpp.lz"); - -static const struct CompressedSpriteSheet gUnknown_082FE6C8[] = -{ - {gPkmnJump321StartGfx1, 0xC00, 0x2000}, - {}, -}; - -static const struct SpritePalette gUnknown_082FE6D8[] = -{ - {gPkmnJump321StartPal1, 0x2000}, - {}, -}; - -static const union AnimCmd sSpriteAnim_82FE6E8[] = -{ - ANIMCMD_FRAME(0, 0), - ANIMCMD_END -}; - -static const union AnimCmd sSpriteAnim_82FE6F0[] = -{ - ANIMCMD_FRAME(16, 0), - ANIMCMD_END -}; - -static const union AnimCmd sSpriteAnim_82FE6F8[] = -{ - ANIMCMD_FRAME(32, 0), - ANIMCMD_END -}; - -static const union AnimCmd sSpriteAnim_82FE700[] = -{ - ANIMCMD_FRAME(64, 0), - ANIMCMD_END -}; - -static const union AnimCmd sSpriteAnim_82FE708[] = -{ - ANIMCMD_FRAME(48, 0), - ANIMCMD_END -}; - -static const union AnimCmd sSpriteAnim_82FE710[] = -{ - ANIMCMD_FRAME(80, 0), - ANIMCMD_END -}; - -static const union AnimCmd *const sSpriteAnimTable_82FE718[] = -{ - sSpriteAnim_82FE6E8, - sSpriteAnim_82FE6F0, - sSpriteAnim_82FE6F8, - sSpriteAnim_82FE700, - sSpriteAnim_82FE708, - sSpriteAnim_82FE710 -}; - -static const struct SpriteTemplate gUnknown_082FE730[] = -{ - { - .tileTag = 0x2000, - .paletteTag = 0x2000, - .oam = &gOamData_AffineOff_ObjNormal_32x32, - .anims = sSpriteAnimTable_82FE718, - .images = NULL, - .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCallbackDummy, - }, -}; - -static const TaskFunc gUnknown_082FE748[][4] = -{ - { - sub_802E83C, - sub_802E8C8, - sub_802EA50, - sub_802EAB0 - }, -}; - -// There's only set of task functions. -static u32 sub_802E63C(u8 funcSetId, u8 taskPriority) -{ - u8 taskId = CreateTask(sub_802E6D0, taskPriority); - struct Task *task = &gTasks[taskId]; - - task->data[0] = 1; - task->data[1] = funcSetId; - gUnknown_082FE748[funcSetId][0](taskId); - return taskId; -} - -static bool32 sub_802E688(void) -{ - u8 taskId = FindTaskIdByFunc(sub_802E6D0); - if (taskId == 0xFF) - return FALSE; - - gTasks[taskId].data[0] = 2; - return TRUE; -} - -static bool32 sub_802E6BC(void) -{ - return FuncIsActiveTask(sub_802E6D0); -} - -static void sub_802E6D0(u8 taskId) -{ - s16 *data = gTasks[taskId].data; - - switch (data[0]) - { - case 2: - gUnknown_082FE748[data[1]][2](taskId); - data[0] = 3; - break; - case 3: - gUnknown_082FE748[data[1]][3](taskId); - break; - case 4: - gUnknown_082FE748[data[1]][1](taskId); - DestroyTask(taskId); - break; - } -} - -static void sub_802E75C(u8 taskId, s16 *data) -{ - u8 i; - struct Sprite *sprite; - - LoadCompressedSpriteSheet(&gUnknown_082FE6C8[data[3]]); - LoadSpritePalette(&gUnknown_082FE6D8[data[4]]); - for (i = 0; i < data[8]; i++) - data[13 + i] = CreateSprite(&gUnknown_082FE730[data[2]], data[9], data[10], data[7]); - for (i = 0; i < data[8]; i++) - { - sprite = &gSprites[data[13 + i]]; - sprite->oam.priority = data[6]; - sprite->invisible = TRUE; - sprite->data[1] = data[5]; - sprite->data[3] = taskId; - sprite->data[4] = i; - sprite->data[5] = data[13]; - } -} - -static void sub_802E83C(u8 taskId) -{ - s16 *data = gTasks[taskId].data; - data[2] = 0; - data[3] = 0; - data[4] = 0; - data[5] = 60; - data[6] = 0; - data[7] = 0; - data[8] = 3; - data[9] = 120; - data[10] = 88; - sub_802E75C(taskId, data); - - StartSpriteAnim(&gSprites[data[14]], 4); - gSprites[data[14]].pos2.x = -32; - - StartSpriteAnim(&gSprites[data[15]], 5); - gSprites[data[15]].pos2.x = 32; -} - -static void sub_802E8C8(u8 taskId) -{ - u8 i = 0; - s16 *data = gTasks[taskId].data; - - for (i = 0; i < data[8]; i++) - DestroySprite(&gSprites[data[13 + i]]); - FreeSpriteTilesByTag(gUnknown_082FE6C8[data[3]].tag); - FreeSpritePaletteByTag(gUnknown_082FE6D8[data[4]].tag); -} - -static void sub_802E938(struct Sprite *sprite) -{ - s16 *data = gTasks[sprite->data[3]].data; - - if (data[11] % data[5] != 0) - return; - if (data[11] == data[10]) - return; - - data[10] = data[11]; - switch (sprite->data[2]) - { - case 0: - sprite->invisible = FALSE; - case 1: - case 2: - PlaySE(SE_KON); - StartSpriteAnim(sprite, sprite->data[2]); - break; - case 3: - PlaySE(SE_PIN); - StartSpriteAnim(sprite, sprite->data[2]); - gSprites[data[14]].invisible = FALSE; - gSprites[data[15]].invisible = FALSE; - break; - case 4: - sprite->invisible = TRUE; - gSprites[data[14]].invisible = TRUE; - gSprites[data[15]].invisible = TRUE; - data[0] = 4; - return; - } - sprite->data[2]++; -} - -static void sub_802EA50(u8 taskId) -{ - s16 *data = gTasks[taskId].data; - PlaySE(SE_KON); - gSprites[data[13]].callback = sub_802E938; - gSprites[data[13]].invisible = FALSE; - gTasks[taskId].data[0] = 3; -} - -static void sub_802EAB0(u8 taskId) -{ - u16 packet[6]; - s16 *data = gTasks[taskId].data; - - if (gReceivedRemoteLinkPlayers != 0) - { - if (gRecvCmds[0][1] == 0x7FFF) - data[11] = gRecvCmds[0][2]; - if (GetMultiplayerId() == 0) - { - data[12]++; - memset(packet, 0, sizeof(packet)); - packet[0] = 0x7FFF; - packet[1] = data[12]; - sub_800FE50(packet); - } - } - else - { - data[11]++; - } -} - -void sub_802EB24(s16 tileTag, s16 palTag, s16 x, s16 y, u8 subpriority) -{ - u8 taskId = CreateTask(sub_802EB98, 0x50); - gTasks[taskId].data[2] = tileTag; - gTasks[taskId].data[3] = palTag; - gTasks[taskId].data[4] = x; - gTasks[taskId].data[5] = y; - gTasks[taskId].data[6] = subpriority; -} - -bool32 sub_802EB84(void) -{ - return FuncIsActiveTask(sub_802EB98); -} - -static void sub_802EB98(u8 taskId) -{ - s16 *data = gTasks[taskId].data; - - switch (data[0]) - { - case 0: - sub_802EF50(data[2], data[3]); - data[7] = sub_802EFA8(data[2], data[3], data[4], data[5], data[6]); - sub_802EFFC(data[2], data[3], data[4], data[5], data[6], &data[8], &data[9]); - data[0]++; - break; - case 1: - if (!sub_802EC98(data[7])) - { - sub_802EDCC(data[7], data[8], data[9]); - FreeSpriteOamMatrix(&gSprites[data[7]]); - DestroySprite(&gSprites[data[7]]); - data[0]++; - } - break; - case 2: - if (!sub_802EE30(data[8])) - { - DestroySprite(&gSprites[data[8]]); - DestroySprite(&gSprites[data[9]]); - FreeSpriteTilesByTag(data[2]); - FreeSpritePaletteByTag(data[3]); - DestroyTask(taskId); - } - break; - } -} - -static bool32 sub_802EC98(u8 spriteId) -{ - struct Sprite *sprite = &gSprites[spriteId]; - - switch (sprite->data[0]) - { - case 0: - sub_8007E18(sprite, 0x800, 0x1A); - sprite->data[0]++; - case 1: - if (sprite->data[2] == 0) - PlaySE(SE_KON2); - if (++sprite->data[2] >= 20) - { - sprite->data[2] = 0; - StartSpriteAffineAnim(sprite, 1); - sprite->data[0]++; - } - break; - case 2: - if (sprite->affineAnimEnded) - sprite->data[0]++; - break; - case 3: - if (++sprite->data[2] >= 4) - { - sprite->data[2] = 0; - sprite->data[0]++; - StartSpriteAffineAnim(sprite, 2); - } - break; - case 4: - sprite->pos1.y -= 4; - if (++sprite->data[2] >= 8) - { - if (sprite->data[4] <= 1) - { - StartSpriteAnim(sprite, sprite->data[4] + 1); - sprite->data[2] = 0; - sprite->data[0]++; - } - else - { - sprite->data[0] = 7; - return FALSE; - } - } - break; - case 5: - sprite->pos1.y += 4; - if (++sprite->data[2] >= 8) - { - sprite->data[2] = 0; - StartSpriteAffineAnim(sprite, 3); - sprite->data[0]++; - } - break; - case 6: - if (sprite->affineAnimEnded) - { - sprite->data[4]++; - sprite->data[0] = 1; - } - break; - case 7: - return FALSE; - } - - return TRUE; -} - -// First argument is unused. -static void sub_802EDCC(u8 spriteId1, u8 spriteId2, u8 spriteId3) -{ - gSprites[spriteId2].pos2.y = -40; - gSprites[spriteId3].pos2.y = -40; - gSprites[spriteId2].invisible = FALSE; - gSprites[spriteId3].invisible = FALSE; - gSprites[spriteId2].callback = sub_802EE5C; - gSprites[spriteId3].callback = sub_802EE5C; -} - -static bool32 sub_802EE30(u8 spriteId) -{ - return (gSprites[spriteId].callback == sub_802EE5C); -} - -static void sub_802EE5C(struct Sprite *sprite) -{ - int y; - s16 *data = sprite->data; - - switch (data[0]) - { - case 0: - data[4] = 64; - data[5] = sprite->pos2.y << 4; - data[0]++; - case 1: - data[5] += data[4]; - data[4]++; - sprite->pos2.y = data[5] >> 4; - if (sprite->pos2.y >= 0) - { - PlaySE(SE_KON2); - sprite->pos2.y = 0; - data[0]++; - } - break; - case 2: - data[1] += 12; - if (data[1] >= 128) - { - PlaySE(SE_KON2); - data[1] = 0; - data[0]++; - } - y = gSineTable[data[1]]; - sprite->pos2.y = -(y >> 4); - break; - case 3: - data[1] += 16; - if (data[1] >= 128) - { - PlaySE(SE_KON2); - data[1] = 0; - data[0]++; - } - sprite->pos2.y = -(gSineTable[data[1]] >> 5); - break; - case 4: - if (++data[1] > 40) - sprite->callback = SpriteCallbackDummy; - break; - } -} - -static const u16 gPkmnJump321StartPal2[] = INCBIN_U16("graphics/link_games/pkmnjump_321start2.gbapal"); -static const u32 gPkmnJump321StartGfx2[] = INCBIN_U32("graphics/link_games/pkmnjump_321start2.4bpp.lz"); - -static void sub_802EF50(u16 tileTag, u16 palTag) -{ - struct CompressedSpriteSheet sprSheet = {gPkmnJump321StartGfx2, 0xE00, 0}; - struct SpritePalette sprPal = {gPkmnJump321StartPal2, 0}; - - sprSheet.tag = tileTag; - sprPal.tag = palTag; - - LoadCompressedSpriteSheet(&sprSheet); - LoadSpritePalette(&sprPal); -} - -static const struct OamData sOamData_82FEBDC = -{ - .y = 0, - .affineMode = ST_OAM_AFFINE_DOUBLE, - .objMode = ST_OAM_OBJ_NORMAL, - .mosaic = 0, - .bpp = ST_OAM_4BPP, - .shape = SPRITE_SHAPE(32x32), - .x = 0, - .matrixNum = 0, - .size = SPRITE_SIZE(32x32), - .tileNum = 0, - .priority = 0, - .paletteNum = 0, - .affineParam = 0 -}; - -static const struct OamData sOamData_82FEBE4 = -{ - .y = 0, - .affineMode = ST_OAM_AFFINE_OFF, - .objMode = ST_OAM_OBJ_NORMAL, - .mosaic = 0, - .bpp = ST_OAM_4BPP, - .shape = SPRITE_SHAPE(64x32), - .x = 0, - .matrixNum = 0, - .size = SPRITE_SIZE(64x32), - .tileNum = 0, - .priority = 0, - .paletteNum = 0, - .affineParam = 0 -}; - -static const union AnimCmd sSpriteAnim_82FEBEC[] = -{ - ANIMCMD_FRAME(0, 1), - ANIMCMD_END -}; - -static const union AnimCmd sSpriteAnim_82FEBF4[] = -{ - ANIMCMD_FRAME(16, 1), - ANIMCMD_END -}; - -static const union AnimCmd sSpriteAnim_82FEBFC[] = -{ - ANIMCMD_FRAME(32, 1), - ANIMCMD_END -}; - -static const union AnimCmd *const sSpriteAnimTable_82FEC04[] = -{ - sSpriteAnim_82FEBEC, - sSpriteAnim_82FEBF4, - sSpriteAnim_82FEBFC -}; - -static const union AnimCmd sSpriteAnim_82FEC10[] = -{ - ANIMCMD_FRAME(48, 1), - ANIMCMD_END -}; - -static const union AnimCmd sSpriteAnim_82FEC18[] = -{ - ANIMCMD_FRAME(80, 1), - ANIMCMD_END -}; - -static const union AnimCmd *const sSpriteAnimTable_82FEC20[] = -{ - sSpriteAnim_82FEC10, - sSpriteAnim_82FEC18 -}; - -static const union AffineAnimCmd sSpriteAffineAnim_82FEC28[] = -{ - AFFINEANIMCMD_FRAME(256, 256, 0, 0), - AFFINEANIMCMD_END -}; - -static const union AffineAnimCmd sSpriteAffineAnim_82FEC38[] = -{ - AFFINEANIMCMD_FRAME(256, 256, 0, 0), - AFFINEANIMCMD_FRAME(16, -16, 0, 8), - AFFINEANIMCMD_END -}; - -static const union AffineAnimCmd sSpriteAffineAnim_82FEC50[] = -{ - AFFINEANIMCMD_FRAME(-18, 18, 0, 8), - AFFINEANIMCMD_END -}; - -static const union AffineAnimCmd sSpriteAffineAnim_82FEC60[] = -{ - AFFINEANIMCMD_FRAME(6, -6, 0, 8), - AFFINEANIMCMD_FRAME(-4, 4, 0, 8), - AFFINEANIMCMD_FRAME(256, 256, 0, 0), - AFFINEANIMCMD_END -}; - -static const union AffineAnimCmd *const sSpriteAffineAnimTable_82FEC80[] = -{ - sSpriteAffineAnim_82FEC28, - sSpriteAffineAnim_82FEC38, - sSpriteAffineAnim_82FEC50, - sSpriteAffineAnim_82FEC60 -}; - -static u8 sub_802EFA8(u16 tileTag, u16 palTag, s16 x, s16 y, u8 subpriority) -{ - u8 spriteId; - struct SpriteTemplate sprTemplate = - { - .tileTag = 0, - .paletteTag = 0, - .oam = &sOamData_82FEBDC, - .anims = sSpriteAnimTable_82FEC04, - .images = NULL, - .affineAnims = sSpriteAffineAnimTable_82FEC80, - .callback = SpriteCallbackDummy, - }; - - sprTemplate.tileTag = tileTag; - sprTemplate.paletteTag = palTag; - spriteId = CreateSprite(&sprTemplate, x, y, subpriority); - return spriteId; -} - -static void sub_802EFFC(u16 tileTag, u16 palTag, s16 x, s16 y, u8 subpriority, s16 *spriteId1, s16 *spriteId2) -{ - struct SpriteTemplate sprTemplate = - { - .tileTag = 0, - .paletteTag = 0, - .oam = &sOamData_82FEBE4, - .anims = sSpriteAnimTable_82FEC20, - .images = NULL, - .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCallbackDummy, - }; - - sprTemplate.tileTag = tileTag; - sprTemplate.paletteTag = palTag; - *spriteId1 = CreateSprite(&sprTemplate, x - 32, y, subpriority); - *spriteId2 = CreateSprite(&sprTemplate, x + 32, y, subpriority); - - gSprites[*spriteId1].invisible = TRUE; - gSprites[*spriteId2].invisible = TRUE; - StartSpriteAnim(&gSprites[*spriteId2], 1); -} diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index 47276fdf9..db6da1495 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -3205,7 +3205,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..dff6b8c6c 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/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..8a15ca30d 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] = { @@ -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_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; } - 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/rom_8034C54.c b/src/rom_8034C54.c deleted file mode 100644 index 029696526..000000000 --- a/src/rom_8034C54.c +++ /dev/null @@ -1,453 +0,0 @@ -#include "global.h" -#include "rom_8034C54.h" -#include "malloc.h" -#include "decompress.h" -#include "main.h" -#include "battle_main.h" - -struct UnkStruct2 -{ - bool8 isActive; - u8 firstOamId; - u8 field_2; - u8 oamCount; - u8 palTagIndex; - u8 size; - u8 shape; - u8 priority; - u8 xDelta; - u8 field_9; - u16 tileStart; - s16 x; - s16 y; - u16 tileTag; - u16 palTag; - u32 field_14; - s32 field_18; -}; - -struct UnkStruct1 -{ - u32 count; - struct UnkStruct2 *array; -}; - -// this file's functions -static u8 sub_8035518(u8 arg0);; -static void sub_8034EFC(struct UnkStruct2 *arg0); -static void sub_80350B0(struct UnkStruct2 *arg0, s32 arg1, bool32 arg2); -static void sub_8035164(struct UnkStruct2 *arg0, s32 arg1, bool32 arg2); -static void sub_80352C0(struct UnkStruct2 *arg0, s32 arg1, bool32 arg2); -static bool32 SharesTileWithAnyActive(u32 id); -static bool32 SharesPalWithAnyActive(u32 id); -static void sub_8035648(void); - -// iwram -static s32 gUnknown_03000DD4; -static s32 gUnknown_03000DD8; -static s32 gUnknown_03000DDC; - -// ewram -static EWRAM_DATA struct UnkStruct1 *gUnknown_02022E10 = {0}; - -// const rom data -static const u8 gUnknown_082FF1C8[][4] = -{ - {0x01, 0x04, 0x10, 0x40}, - {0x02, 0x04, 0x08, 0x20}, - {0x02, 0x04, 0x08, 0x20}, - {0x00, 0x00, 0x00, 0x00} -}; - -// code -bool32 sub_8034C54(u32 count) -{ - u32 i; - - if (gUnknown_02022E10 != NULL) - sub_8034CC8(); - - gUnknown_02022E10 = Alloc(sizeof(*gUnknown_02022E10)); - if (gUnknown_02022E10 == NULL) - return FALSE; - - gUnknown_02022E10->array = Alloc(sizeof(struct UnkStruct2) * count); - if (gUnknown_02022E10->array == NULL) - { - Free(gUnknown_02022E10); - return FALSE; - } - - gUnknown_02022E10->count = count; - for (i = 0; i < count; i++) - { - gUnknown_02022E10->array[i].isActive = FALSE; - gUnknown_02022E10->array[i].firstOamId = 0xFF; - } - - return TRUE; -} - -void sub_8034CC8(void) -{ - if (gUnknown_02022E10 != NULL) - { - if (gUnknown_02022E10->array != NULL) - { - u32 i; - - for (i = 0; i < gUnknown_02022E10->count; i++) - sub_80353DC(i); - - Free(gUnknown_02022E10->array); - } - - FREE_AND_SET_NULL(gUnknown_02022E10); - } -} - -bool32 sub_8034D14(u32 id, s32 arg1, const struct UnkStruct3 *arg2) -{ - u32 i; - - if (gUnknown_02022E10 == NULL) - return FALSE; - if (gUnknown_02022E10->array[id].isActive) - return FALSE; - - gUnknown_02022E10->array[id].firstOamId = sub_8035518(arg2->field_1); - if (gUnknown_02022E10->array[id].firstOamId == 0xFF) - return FALSE; - - gUnknown_02022E10->array[id].tileStart = GetSpriteTileStartByTag(arg2->spriteSheet->tag); - if (gUnknown_02022E10->array[id].tileStart == 0xFFFF) - { - if (arg2->spriteSheet->size != 0) - { - gUnknown_02022E10->array[id].tileStart = LoadSpriteSheet(arg2->spriteSheet); - } - else - { - struct CompressedSpriteSheet compSpriteSheet; - - compSpriteSheet = *(struct CompressedSpriteSheet*)(arg2->spriteSheet); - compSpriteSheet.size = GetDecompressedDataSize(arg2->spriteSheet->data); - gUnknown_02022E10->array[id].tileStart = LoadCompressedSpriteSheet(&compSpriteSheet); - } - - if (gUnknown_02022E10->array[id].tileStart == 0xFFFF) - return FALSE; - } - - gUnknown_02022E10->array[id].palTagIndex = IndexOfSpritePaletteTag(arg2->spritePal->tag); - if (gUnknown_02022E10->array[id].palTagIndex == 0xFF) - gUnknown_02022E10->array[id].palTagIndex = LoadSpritePalette(arg2->spritePal); - - gUnknown_02022E10->array[id].field_2 = arg2->field_0_0; - gUnknown_02022E10->array[id].oamCount = arg2->field_1; - gUnknown_02022E10->array[id].x = arg2->x; - gUnknown_02022E10->array[id].y = arg2->y; - gUnknown_02022E10->array[id].shape = arg2->shape; - gUnknown_02022E10->array[id].size = arg2->size; - gUnknown_02022E10->array[id].priority = arg2->priority; - gUnknown_02022E10->array[id].xDelta = arg2->xDelta; - gUnknown_02022E10->array[id].field_9 = sub_80355F8(arg2->shape, arg2->size); - gUnknown_02022E10->array[id].tileTag = arg2->spriteSheet->tag; - gUnknown_02022E10->array[id].palTag = arg2->spritePal->tag; - gUnknown_02022E10->array[id].isActive = TRUE; - gUnknown_02022E10->array[id].field_14 = 1; - - for (i = 1; i < arg2->field_1; i++) - gUnknown_02022E10->array[id].field_14 *= 10; - - sub_8034EFC(&gUnknown_02022E10->array[id]); - sub_8035044(id, arg1); - - return TRUE; -} - -static void sub_8034EFC(struct UnkStruct2 *arg0) -{ - u32 i; - u32 oamId = arg0->firstOamId; - u32 x = arg0->x; - u32 oamCount = arg0->oamCount + 1; - - CpuFill16(0, &gMain.oamBuffer[oamId], sizeof(struct OamData) * oamCount); - for (i = 0, oamId = arg0->firstOamId; i < oamCount; i++, oamId++) - { - gMain.oamBuffer[oamId].y = arg0->y; - gMain.oamBuffer[oamId].x = x; - gMain.oamBuffer[oamId].shape = arg0->shape; - gMain.oamBuffer[oamId].size = arg0->size; - gMain.oamBuffer[oamId].tileNum = arg0->tileStart; - gMain.oamBuffer[oamId].priority = arg0->priority; - gMain.oamBuffer[oamId].paletteNum = arg0->palTagIndex; - - x += arg0->xDelta; - } - - oamId--; - gMain.oamBuffer[oamId].x = arg0->x - arg0->xDelta; - gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_ERASE; - gMain.oamBuffer[oamId].tileNum = arg0->tileStart + (arg0->field_9 * 10); -} - -void sub_8035044(u32 id, s32 arg1) -{ - bool32 r2; - - if (gUnknown_02022E10 == NULL) - return; - if (!gUnknown_02022E10->array[id].isActive) - return; - - gUnknown_02022E10->array[id].field_18 = arg1; - if (arg1 < 0) - { - r2 = TRUE; - arg1 *= -1; - } - else - { - r2 = FALSE; - } - - switch (gUnknown_02022E10->array[id].field_2) - { - case 0: - default: - sub_80350B0(&gUnknown_02022E10->array[id], arg1, r2); - break; - case 1: - sub_8035164(&gUnknown_02022E10->array[id], arg1, r2); - break; - case 2: - sub_80352C0(&gUnknown_02022E10->array[id], arg1, r2); - break; - } -} - -static void sub_80350B0(struct UnkStruct2 *arg0, s32 arg1, bool32 arg2) -{ - u32 r5 = arg0->field_14; - u32 oamId = arg0->firstOamId; - - while (r5 != 0) - { - u32 r4 = arg1 / r5; - arg1 -= (r4 * r5); - r5 /= 10; - - gMain.oamBuffer[oamId].tileNum = (r4 * arg0->field_9) + arg0->tileStart; - oamId++; - } - - if (arg2) - gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_OFF; - else - gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_ERASE; -} - -static void sub_8035164(struct UnkStruct2 *arg0, s32 arg1, bool32 arg2) -{ - u32 r5 = arg0->field_14; - gUnknown_03000DD4 = arg0->firstOamId; - gUnknown_03000DD8 = 0; - gUnknown_03000DDC = -1; - - while (r5 != 0) - { - u32 r4 = arg1 / r5; - arg1 -= (r4 * r5); - r5 /= 10; - - if (r4 != 0 || gUnknown_03000DDC != -1 || r5 == 0) - { - gMain.oamBuffer[gUnknown_03000DD4].tileNum = (r4 * arg0->field_9) + arg0->tileStart; - gMain.oamBuffer[gUnknown_03000DD4].affineMode = ST_OAM_AFFINE_OFF; - - if (gUnknown_03000DDC == -1) - gUnknown_03000DDC = gUnknown_03000DD8; - } - else - { - gMain.oamBuffer[gUnknown_03000DD4].affineMode = ST_OAM_AFFINE_ERASE; - } - - gUnknown_03000DD4++; - gUnknown_03000DD8++; - } - - if (arg2) - { - gMain.oamBuffer[gUnknown_03000DD4].affineMode = ST_OAM_AFFINE_OFF; - gMain.oamBuffer[gUnknown_03000DD4].x = arg0->x + ((gUnknown_03000DDC - 1) * arg0->xDelta); - } - else - { - gMain.oamBuffer[gUnknown_03000DD4].affineMode = ST_OAM_AFFINE_ERASE; - } -} - -static void sub_80352C0(struct UnkStruct2 *arg0, s32 arg1, bool32 arg2) -{ - u32 r5 = arg0->field_14; - u32 oamId = arg0->firstOamId; - u32 var_28 = 0; - s32 r9 = 0; - - while (r5 != 0) - { - u32 r4 = arg1 / r5; - arg1 -= (r4 * r5); - r5 /= 10; - - if (r4 != 0 || var_28 != 0 || r5 == 0) - { - var_28 = 1; - gMain.oamBuffer[oamId].tileNum = (r4 * arg0->field_9) + arg0->tileStart; - gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_OFF; - - oamId++; - r9++; - } - } - - while (r9 < arg0->oamCount) - { - gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_ERASE; - oamId++; - r9++; - } - - if (arg2) - gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_OFF; - else - gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_ERASE; -} - -void sub_80353DC(u32 id) -{ - s32 oamId, oamCount, i; - - if (gUnknown_02022E10 == NULL) - return; - if (!gUnknown_02022E10->array[id].isActive) - return; - - oamCount = gUnknown_02022E10->array[id].oamCount + 1; - oamId = gUnknown_02022E10->array[id].firstOamId; - - for (i = 0; i < oamCount; i++, oamId++) - gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_ERASE; - - if (!SharesTileWithAnyActive(id)) - FreeSpriteTilesByTag(gUnknown_02022E10->array[id].tileTag); - if (!SharesPalWithAnyActive(id)) - FreeSpritePaletteByTag(gUnknown_02022E10->array[id].palTag); - - gUnknown_02022E10->array[id].isActive = FALSE; -} - -void sub_803547C(u32 id, bool32 arg1) -{ - s32 oamId, oamCount, i; - - if (gUnknown_02022E10 == NULL) - return; - if (!gUnknown_02022E10->array[id].isActive) - return; - - oamCount = gUnknown_02022E10->array[id].oamCount + 1; - oamId = gUnknown_02022E10->array[id].firstOamId; - if (arg1) - { - for (i = 0; i < oamCount; i++, oamId++) - gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_ERASE; - } - else - { - for (i = 0; i < oamCount; i++, oamId++) - gMain.oamBuffer[oamId].affineMode = ST_OAM_AFFINE_OFF; - - sub_8035044(id, gUnknown_02022E10->array[id].field_18); - } -} - -static u8 sub_8035518(u8 arg0) -{ - u32 i; - u16 oamCount = 64; - - for (i = 0; i < gUnknown_02022E10->count; i++) - { - if (!gUnknown_02022E10->array[i].isActive) - { - if (gUnknown_02022E10->array[i].firstOamId != 0xFF && gUnknown_02022E10->array[i].oamCount <= arg0) - return gUnknown_02022E10->array[i].firstOamId; - } - else - { - oamCount += 1 + gUnknown_02022E10->array[i].oamCount; - } - } - - if (oamCount + arg0 + 1 > 128) - return 0xFF; - else - return oamCount; -} - -static bool32 SharesTileWithAnyActive(u32 id) -{ - u32 i; - - for (i = 0; i < gUnknown_02022E10->count; i++) - { - if (gUnknown_02022E10->array[i].isActive && i != id - && gUnknown_02022E10->array[i].tileTag == gUnknown_02022E10->array[id].tileTag) - { - return TRUE; - } - } - - return FALSE; -} - -static bool32 SharesPalWithAnyActive(u32 id) -{ - u32 i; - - for (i = 0; i < gUnknown_02022E10->count; i++) - { - if (gUnknown_02022E10->array[i].isActive && i != id - && gUnknown_02022E10->array[i].palTag == gUnknown_02022E10->array[id].palTag) - { - return TRUE; - } - } - - return FALSE; -} - -u8 sub_80355F8(u32 shape, u32 size) -{ - return gUnknown_082FF1C8[shape][size]; -} - -static void sub_8035608(void) -{ - u8 spriteId; - - ResetSpriteData(); - spriteId = CreateSprite(&gUnknown_0831AC88, 0, 0, 0); - gSprites[spriteId].invisible = TRUE; - SetMainCallback2(sub_8035648); -} - -static void sub_8035648(void) -{ - AnimateSprites(); - BuildOamBuffer(); -} diff --git a/src/rom_81520A8.c b/src/rom_81520A8.c index f6d14d49c..8b10d44d0 100644 --- a/src/rom_81520A8.c +++ b/src/rom_81520A8.c @@ -2,7 +2,7 @@ #include "rom_81520A8.h" #include "malloc.h" #include "main.h" -#include "rom_8034C54.h" +#include "digit_obj_util.h" static EWRAM_DATA struct { @@ -138,7 +138,7 @@ static bool32 sub_81523F4(struct UnkStruct_81520A8 *structPtr, u8 arg1) return FALSE; structPtr->unk18 = arg1; - structPtr->tileNum = (sub_80355F8(structPtr->oam.shape, structPtr->oam.size) * arg1) + tileStart; + structPtr->tileNum = (GetTilesPerImage(structPtr->oam.shape, structPtr->oam.size) * arg1) + tileStart; return TRUE; } diff --git a/src/secret_base.c b/src/secret_base.c index 31fd901e0..ec48e9b51 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -543,23 +543,23 @@ void InitSecretBaseDecorationSprites(void) objectEventId = 0; if (!CurMapIsSecretBase()) { - decorations = gSaveBlock1Ptr->playerRoomDecor; - decorationPositions = gSaveBlock1Ptr->playerRoomDecorPos; - numDecorations = 12; + decorations = gSaveBlock1Ptr->playerRoomDecorations; + decorationPositions = gSaveBlock1Ptr->playerRoomDecorationPositions; + numDecorations = DECOR_MAX_PLAYERS_HOUSE; } else { u16 secretBaseId = VarGet(VAR_CURRENT_SECRET_BASE); decorations = gSaveBlock1Ptr->secretBases[secretBaseId].decorations; decorationPositions = gSaveBlock1Ptr->secretBases[secretBaseId].decorationPositions; - numDecorations = 16; + numDecorations = DECOR_MAX_SECRET_BASE; } for (i = 0; i < numDecorations; i++) { if (decorations[i] == DECOR_NONE) continue; - + permission = gDecorations[decorations[i]].permission; category = gDecorations[decorations[i]].category; if (permission == DECORPERM_SPRITE) diff --git a/src/start_menu.c b/src/start_menu.c index a6e7ae5d8..4b6fce57b 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -603,7 +603,7 @@ static bool8 StartMenuPokedexCallback(void) PlayRainStoppingSoundEffect(); RemoveExtraStartMenuWindows(); CleanupOverworldWindowsAndTilemaps(); - SetMainCallback2(CB2_Pokedex); + SetMainCallback2(CB2_OpenPokedex); return TRUE; } diff --git a/src/trader.c b/src/trader.c index e0b780d25..ac6a30df0 100644 --- a/src/trader.c +++ b/src/trader.c @@ -42,7 +42,7 @@ void TraderSetup(void) for (i = 0; i < 4; i++) { StringCopy(trader->playerNames[i], sDefaultTraderNames[i]); - trader->decorIds[i] = sDefaultTraderDecorations[i]; + trader->decorations[i] = sDefaultTraderDecorations[i]; trader->language[i] = GAME_LANGUAGE; } } @@ -64,10 +64,10 @@ void CreateAvailableDecorationsMenu(u8 taskId) for (i = 0; i < 4; i++) { s32 curWidth; - if (trader->decorIds[i] > NUM_DECORATIONS) + if (trader->decorations[i] > NUM_DECORATIONS) curWidth = fiveMarksWidth; else - curWidth = GetStringWidth(1, gDecorations[trader->decorIds[i]].name, 0); + curWidth = GetStringWidth(1, gDecorations[trader->decorations[i]].name, 0); if (curWidth > windowWidth) windowWidth = curWidth; } @@ -76,10 +76,10 @@ void CreateAvailableDecorationsMenu(u8 taskId) DrawStdFrameWithCustomTileAndPalette(data[3], FALSE, 0x214, 14); for (i = 0; i < 4; i++) { - if (trader->decorIds[i] > NUM_DECORATIONS) + if (trader->decorations[i] > NUM_DECORATIONS) AddTextPrinterParameterized(data[3], 1, gText_FiveMarks, 8, 16 * i + 1, 255, NULL); else - AddTextPrinterParameterized(data[3], 1, gDecorations[trader->decorIds[i]].name, 8, 16 * i + 1, 255, NULL); + AddTextPrinterParameterized(data[3], 1, gDecorations[trader->decorations[i]].name, 8, 16 * i + 1, 255, NULL); } AddTextPrinterParameterized(data[3], 1, gText_Exit, 8, 16 * i + 1, 255, NULL); InitMenuInUpperLeftCornerPlaySoundWhenAPressed(data[3], 5, 0); @@ -125,7 +125,7 @@ void Task_HandleGetDecorationMenuInput(u8 taskId) gSpecialVar_0x8005 = input; StringCopy(gStringVar1, trader->playerNames[input]); ConvertInternationalString(gStringVar1, trader->language[input]); - Task_BufferDecorSelectionAndCloseWindow(taskId, trader->decorIds[input]); + Task_BufferDecorSelectionAndCloseWindow(taskId, trader->decorations[input]); break; } } @@ -167,7 +167,7 @@ void ScrSpecial_TraderMenuGiveDecoration(void) CreateTask(ShowDecorationCategoriesWindow, 0); } -void sub_8133DA0(u8 taskId) +void DecorationItemsMenuAction_Trade(u8 taskId) { if (IsSelectedDecorInThePC() == TRUE) { @@ -197,7 +197,7 @@ void ScrSpecial_TraderDoDecorationTrade(void) DecorationRemove(gSpecialVar_0x8006); DecorationAdd(gSpecialVar_0x8004); StringCopy(trader->playerNames[gSpecialVar_0x8005], gSaveBlock2Ptr->playerName); - trader->decorIds[gSpecialVar_0x8005] = gSpecialVar_0x8006; + trader->decorations[gSpecialVar_0x8005] = gSpecialVar_0x8006; trader->language[gSpecialVar_0x8005] = GAME_LANGUAGE; trader->alreadyTraded = TRUE; } diff --git a/src/union_room_battle.c b/src/union_room_battle.c index c80340da3..18dd7c320 100644 --- a/src/union_room_battle.c +++ b/src/union_room_battle.c @@ -451,15 +451,15 @@ void sub_801AAD4(void) { s32 i; sub_8014210(10); - for (i = 0; i < 2; i++) + for (i = 0; i < UNION_ROOM_PARTY_SIZE; i++) { gEnemyParty[i] = gPlayerParty[gSelectedOrderFromParty[i] - 1]; } - for (i = 0; i < 6; i++) + for (i = 0; i < PARTY_SIZE; i++) { ZeroMonData(&gPlayerParty[i]); } - for (i = 0; i < 2; i++) + for (i = 0; i < UNION_ROOM_PARTY_SIZE; i++) { gPlayerParty[i] = gEnemyParty[i]; } 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/src/use_pokeblock.c b/src/use_pokeblock.c index a0c8d8e2d..5079edb37 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -937,62 +937,24 @@ void Pokeblock_MenuWindowTextPrint(const u8 *message) AddTextPrinterParameterized(2, 1, gStringVar4, 0, 1, 0, NULL); } -// This function is a joke. -#ifdef NONMATCHING void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statId, s16 a2) { - if (a2 != 0) + switch (a2) { + case 1 ... 32767: + a2 = 0; + // fallthrough + case -32768 ... -1: + if (a2) + dest[(u16)a2] += 0; // something you can't imagine StringCopy(dest, sContestStatNames[statId]); StringAppend(dest, gText_WasEnhanced); - } - else - { + break; + case 0: StringCopy(dest, gText_NothingChanged); + break; } } -#else -NAKED -void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statId, s16 a2) -{ - asm(".syntax unified\n\ -push {r4,lr}\n\ - adds r4, r0, 0\n\ - lsls r1, 24\n\ - lsrs r3, r1, 24\n\ - lsls r2, 16\n\ - lsrs r0, r2, 16\n\ - asrs r2, 16\n\ - cmp r2, 0\n\ - beq _08167010\n\ - cmp r2, 0\n\ - ble _08166FEC\n\ - movs r0, 0\n\ -_08166FEC:\n\ - lsls r0, 16\n\ - ldr r1, =sContestStatNames\n\ - lsls r0, r3, 2\n\ - adds r0, r1\n\ - ldr r1, [r0]\n\ - adds r0, r4, 0\n\ - bl StringCopy\n\ - ldr r1, =gText_WasEnhanced\n\ - adds r0, r4, 0\n\ - bl StringAppend\n\ - b _08167018\n\ - .pool\n\ -_08167010:\n\ - ldr r1, =gText_NothingChanged\n\ - adds r0, r4, 0\n\ - bl StringCopy\n\ -_08167018:\n\ - pop {r4}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ - .syntax divided\n"); -} -#endif void Pokeblock_GetMonContestStats(struct Pokemon *mon, u8 *data) { diff --git a/sym_bss.txt b/sym_bss.txt index 1c58146f6..aad8c8f14 100644 --- a/sym_bss.txt +++ b/sym_bss.txt @@ -14,7 +14,7 @@ .include "src/dodrio_berry_picking.o" .include "src/rtc.o" .include "src/main_menu.o" - .include "src/rom_8034C54.o" + .include "src/digit_obj_util.o" .include "src/egg_hatch.o" .include "src/berry_blender.o" .include "src/play_time.o" diff --git a/sym_ewram.txt b/sym_ewram.txt index 5e6eef5ef..d00f7953c 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -23,7 +23,7 @@ .include "src/pokemon_jump.o" .include "src/main_menu.o" .include "src/battle_controllers.o" - .include "src/rom_8034C54.o" + .include "src/digit_obj_util.o" .include "src/battle_main.o" .include "src/pokemon.o" .include "src/random.o" @@ -139,7 +139,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"